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. IF STATEMENT

IF STATEMENT

Scheduled Pinned Locked Moved Visual Basic
beta-testingregexhelpcode-review
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.
  • F Offline
    F Offline
    Fountain
    wrote on last edited by
    #1

    Hello, I am new to VBA (self taught) and I'm looking for a shortcut on writing an IF STATEMENT. I have an Excel spreadsheet that contains 3,070 rows of Bin Numbers. The report is similar to the below columns. 510250000 510250999 510251000 510251999 510252000 510252999 510253000 510253999 Soon I will receive a report on a daily basis, which will need to be bumped next to these bin numbers looking for a match. I wrote the following IF STATEMENT If strbin >= 510250000 and <= 510250999 _ or strbin >= 510251000 and <= 510251999 _ or strbin >= 510252000 and <= 510252999 _ then Cells(irow, 1).Interior.ColorIndex = 34 As mentioned above, by the time I've completed the above statement I will have over 3,000 rows. I would appreciate any feedback on a shortcut. Thank you in advance for your help. Fountain

    D 1 Reply Last reply
    0
    • F Fountain

      Hello, I am new to VBA (self taught) and I'm looking for a shortcut on writing an IF STATEMENT. I have an Excel spreadsheet that contains 3,070 rows of Bin Numbers. The report is similar to the below columns. 510250000 510250999 510251000 510251999 510252000 510252999 510253000 510253999 Soon I will receive a report on a daily basis, which will need to be bumped next to these bin numbers looking for a match. I wrote the following IF STATEMENT If strbin >= 510250000 and <= 510250999 _ or strbin >= 510251000 and <= 510251999 _ or strbin >= 510252000 and <= 510252999 _ then Cells(irow, 1).Interior.ColorIndex = 34 As mentioned above, by the time I've completed the above statement I will have over 3,000 rows. I would appreciate any feedback on a shortcut. Thank you in advance for your help. Fountain

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Uhhh...Your IF statement doesn't have to be multiple ranges like that, because, so far, your range is 510250000 to 510252999, with no breaks between the ranges you listed! What's the logic behind what you want to do? So far, all we've seen is that your coloring cells, but why? What determines what color the cell is going to be? And what is the problem that your having? Is it performance related? RageInTheMachine9532

      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