+ Reply to Thread
Results 1 to 3 of 3

Select Case in a Range

Hybrid View

  1. #1
    Registered User
    Join Date
    04-30-2010
    Location
    Moose Jaw, SK
    MS-Off Ver
    Excel 2007
    Posts
    8

    Select Case in a Range

    I need to loop through a range of cells - Range("AH2", Range("AH65536").End(xlUp)) - and if a certain value is found another value needs to be placed in the cell directly to the right .

    I was thinking that Select Case would be the simplest method, but how do i loop through the Range in AH2 and how do I place a value in the cell to the right?

    Thanks in advance for any and all help!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Select Case in a Range

    Hello prairied0gg,

    Like this. Just change the comparisons and the data to go into the cell at the right.
    Sub Macro1()
    
      Dim Cell As Range
      Dim Rng As Range
    
        Set Rng = Range("AH2", Range("AH65536").End(xlUp)) 
    
          For Each Cell In Rng
            Select Case Cell.Value
              Case Is = "This", "That", "Something else"
                Cell.Offset(0, 1) = "New data"
            End Select
          Next Cell
    
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-30-2010
    Location
    Moose Jaw, SK
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Select Case in a Range

    Leith,
    Thank-you so much for your help. This is precisely what I was looking for.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1