Excel VBA Reffering to Active Cell

B

bjshots

I would like to refer to the Range of the ActiveCell in code

dim MyNum as integer

for MyNum = 25 to 50 Step 1
If ActiveCell = Range("C" & MyNum) then
Range("C" & MyNum) = "Hello World"
end if
next

I have tried ActiveCell.Range but then I receive an Error from VBA.
I have been able to extract the value from the active cell but I wan
to test for the range.

thanks
BjShot
 
C

Chip Pearson

I'm not entirely sure what you're after, but something like

For MyNum = 25 To 50
If ActiveCell.Address = Range("C" & MyNum).Address Then
Range("C" & MyNum).Value = "Hello World"
End If
Next MyNum


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
B

bjshots

Thank You Chip

That is exactly the answer to my problem. I appreciate your quic
response


thanks again
BjShot
 
Top