LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Dynamic Range based on cell contents

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink to Named Range Based On Cell Contents TKS_Mark Excel Worksheet Functions 1 January 9th 08 04:14 PM
Reference Data Range based on cell contents PCLIVE Charts and Charting in Excel 0 February 27th 06 03:01 PM
copying dynamic range based on cell outside of range xcelelder Excel Programming 3 September 29th 05 05:08 PM
Set range based on cell contents - help required N E Body[_4_] Excel Programming 5 July 27th 04 02:48 PM
Dynamic Range Names & Clear Cell Contents Q John[_78_] Excel Programming 1 June 13th 04 01:59 PM


All times are GMT +1. The time now is 06:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"