+ Reply to Thread
Results 1 to 3 of 3

Looping through cells using VBA

Hybrid View

Guest Looping through cells using... 12-21-2005, 02:30 PM
Guest Re: Looping through cells... 12-21-2005, 02:50 PM
Guest Re: Looping through cells... 12-21-2005, 08:15 PM
  1. #1
    Ann
    Guest

    Looping through cells using VBA

    I need to look through a range of cells to see if there is a match to a
    variable I have previously set. What is the syntax for referencing this
    range? Thanks.

  2. #2
    Tom Ogilvy
    Guest

    Re: Looping through cells using VBA

    Dim rng as Range, rng1 as Range
    Dim myVar as String

    myVar = "Amy"
    set rng = Range("B9:F100")

    set rng1 = rng.find(myVar)
    if not rng1 is nothing then
    msgbox myvar & " found at " & rng1.Address
    Else
    msgbox myvar & " was not found in " & rng.Address
    End sub

    --
    Regards,
    Tom Ogilvy

    "Ann" <Ann@discussions.microsoft.com> wrote in message
    news:ABEFB9AF-BF85-4BDC-9290-AF9AA1AFE1B6@microsoft.com...
    > I need to look through a range of cells to see if there is a match to a
    > variable I have previously set. What is the syntax for referencing this
    > range? Thanks.




  3. #3
    Nexus
    Guest

    Re: Looping through cells using VBA

    For Each c In Range("A1:A10")
    If c.Text = "WHATEVER YOUR LOOKING FOR" Then
    ..... Do what you want here
    End If
    Next c

    In the example change the range to whatever you want and the check
    condition.

    This way you have multiple check conditions within a case statement and as
    each cell is returned you can manipulate each cell very easily.

    "Ann" <Ann@discussions.microsoft.com> wrote in message
    news:ABEFB9AF-BF85-4BDC-9290-AF9AA1AFE1B6@microsoft.com...
    >I need to look through a range of cells to see if there is a match to a
    > variable I have previously set. What is the syntax for referencing this
    > range? Thanks.




+ 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