Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Excel column formatting issue, format style changed when formatted again with the same style

Excel column formatting issue, format style changed when formatted again with the same style

Scheduled Pinned Locked Moved Visual Basic
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BREdwards
    wrote on last edited by
    #1

    Hello, I am in the process of trying to fix this bug that has cropped up in some code I am maintaining. The issue is this: The application runs through some data from an excel spreadsheet and when it is finished, it formats and saves the spreadsheet before closing it out. This works, but heres the thing, when a spreadsheet is run through the app the first time, the columns are formatted correctly as Currency, but when the same spreadsheet is run again, the columns formatted as Currency are now formatted as Accounting for some reason even though the lines of code doing the formatting clearly state Currency like this: objExcelSheet.Columns(eSheetLocations.AMT).Style = "Currency" This is proving to be one heck of a noodle scratcher, as I have no clue why it is doing this. I had originally considered a workaround by trying to get the current style by having a variable set to it, but the variable returns Nothing when I step through. The reason I need this to stay Currency is because zero-dollar amounts need to be seen as "$0.00" and not "-" as this confuses the end users. Any help and advice is welcome, thanks in advance.

    J 1 Reply Last reply
    0
    • B BREdwards

      Hello, I am in the process of trying to fix this bug that has cropped up in some code I am maintaining. The issue is this: The application runs through some data from an excel spreadsheet and when it is finished, it formats and saves the spreadsheet before closing it out. This works, but heres the thing, when a spreadsheet is run through the app the first time, the columns are formatted correctly as Currency, but when the same spreadsheet is run again, the columns formatted as Currency are now formatted as Accounting for some reason even though the lines of code doing the formatting clearly state Currency like this: objExcelSheet.Columns(eSheetLocations.AMT).Style = "Currency" This is proving to be one heck of a noodle scratcher, as I have no clue why it is doing this. I had originally considered a workaround by trying to get the current style by having a variable set to it, but the variable returns Nothing when I step through. The reason I need this to stay Currency is because zero-dollar amounts need to be seen as "$0.00" and not "-" as this confuses the end users. Any help and advice is welcome, thanks in advance.

      J Offline
      J Offline
      Johan Hakkesteegt
      wrote on last edited by
      #2

      That is strange, but then again you should always expect surprises from MickeySoft. A simple work around would be to somehow flag the spreadsheet when you run it through the app, and checking for that flag first when you get to the style changing bit. Not flagged = set style, and flag Flagged = skip style setting, and leave the flag be.

      My advice is free, and you may get what you paid for.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups