Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel 2003
I am trying to use a macro to search column a for the Text "RD". I have used the code below many times to find each instance in a column. Now, I want to find each instance, but after one instance, assign the value to a variable, go to the next instance, assign that to a variable, and then perform some operations. on that range. I'm only concerned at this point with getting the selection and variable assignments to work. The code below works for the first instance, but always assigns 5 to J. I am stumped. Thanks in advance for any help. Sub SelectRDRows() Dim I As Long Dim J As Long Dim BegCell As Long Dim EndCell As Long For I = Range("A65536").End(xlUp).Row To 1 Step -1 If Range("A" & I).Value = "RD" Then EndCell = I - 1 For J = Range("A" & EndCell).End(xlUp).Row To 1 Step -1 If Range("A" & J).Value = "RD" Then BegCell = J + 1 Range("A" & BegCell & ":" & "A" & EndCell).Select Exit For End If Next J End If Next I End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Hyperlink to Named Range Based On Cell Contents | Excel Worksheet Functions | |||
Reference Data Range based on cell contents | Charts and Charting in Excel | |||
copying dynamic range based on cell outside of range | Excel Programming | |||
Set range based on cell contents - help required | Excel Programming | |||
Dynamic Range Names & Clear Cell Contents Q | Excel Programming |