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. VB6 - formatting an Excel column

VB6 - formatting an Excel column

Scheduled Pinned Locked Moved Visual Basic
questionlounge
4 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.
  • S Offline
    S Offline
    steff kamush
    wrote on last edited by
    #1

    How can I change an Excel worksheet column's format in vb6. I can open an Excel app and write to it, but if I write text like "00100" it loses the 0's and becomes "100" because the column format is General. How can I change it to Text in code? :rose::rose: 1fm1fu

    J 1 Reply Last reply
    0
    • S steff kamush

      How can I change an Excel worksheet column's format in vb6. I can open an Excel app and write to it, but if I write text like "00100" it loses the 0's and becomes "100" because the column format is General. How can I change it to Text in code? :rose::rose: 1fm1fu

      J Offline
      J Offline
      jonathan15
      wrote on last edited by
      #2

      The quick way to do it is to use "'00100" or write a quick function to append the ' to the front of the value. Or set the numberformat property for the range then the value as below: Dim c As Range Set c = Worksheets("Sheet1").Range("A1") c.NumberFormat = "@" c.Value = "00100"

      S 1 Reply Last reply
      0
      • J jonathan15

        The quick way to do it is to use "'00100" or write a quick function to append the ' to the front of the value. Or set the numberformat property for the range then the value as below: Dim c As Range Set c = Worksheets("Sheet1").Range("A1") c.NumberFormat = "@" c.Value = "00100"

        S Offline
        S Offline
        steff kamush
        wrote on last edited by
        #3

        Thanx jonathan15, this works. I'll try hard and convince Christine, my code tester, not to worry about the mark this makes in the cell. :rose::rose: 1fm1fu

        J 1 Reply Last reply
        0
        • S steff kamush

          Thanx jonathan15, this works. I'll try hard and convince Christine, my code tester, not to worry about the mark this makes in the cell. :rose::rose: 1fm1fu

          J Offline
          J Offline
          jonathan15
          wrote on last edited by
          #4

          If you use the second method the only mark it will leave will be a green tab in the top left corner of the cell which is simply there to show that it is a number formatted as text. This would be there even if you used the Excel menu to format the cell. Jonathan

          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