View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
RH[_2_] RH[_2_] is offline
external usenet poster
 
Posts: 3
Default What does this do?

Alright Tim,

My brain is smking now!

;-)


Bob

-----Original Message-----

Dim rng as Range, rng1 as Range, rng2 as Range
Dim cell as Range

'find the bottom of the data in Column A, search from A1
' to the bottom of the data
set rng = Range(Cells(1,1),Cells(rows.count,1).end(xlup))
for each cell in rng
if cell.Value = "Target1" and rng1 is nothing then _
set rng1 = cell
if cell.Value = "Target2" and rng2 is nothing then
set rng2 = cell
exit for
end if
Next

if not rng1 is nothing and not rng2 is nothing then
Range(rng1,rng2).EntireRow.Select
else
msgbox "at least one target not found"
End if


--
Regards,
Tom Ogilvy

"RH" wrote in message
...
Thanks for the folowups guys! now I get it!!

Now that I got the loop worked out,I have another
question...

I want to modify my code to search for a cell with a
specific value in it, then search for ANOTHER cell with

a
specific value and then select all the ENTIRE ROWS that
are between the two cells it found.

I've been trying to use the range object to do this, but
I'm so rusty!! I only get to do VBA/Excel programming
about once per year. So, I'm having a hard time with it.
Any pointers??

-----Original Message-----
RH,

RNum is simply a variable used as a counter in the

For ... Next loop. First
time through the loop it will be set to 1, 2 on the

second, etc. until it
gets to the value in MRow. Typically it will be used in

the loop to refer to
something else.

MRow is just a numeric value of the number input by the

user at the start,
with 10 added.

--

HTH

Bob Phillips

"RH" wrote

in
message
...
I'm working on an Excel project and ran across this

code
snippet:

###########################
temp = InputBox(prompt:="Enter the Number of the last

row
shown on the screen (i.e. 1130):", _
Title:="Length of File",
Default:="2000")
If temp = "" Then
MsgBox prompt:="Convert Data Procedure
Canceled."
Range("a1").Select
Exit Sub
Else
End If
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
MRow = CSng(temp +
10) 'Converts temp from

string
to
number
counter1 = 0
For Rnum = 1 To MRow

##############################

So, in this case....What is RNUM? I don't understand
the "= 1 TO MROW" here.

Can someone elaborate please?

Thanks!
Bob


.



.