Excel VBA Reffering to Active Cell

  • Thread starter Thread starter bjshots
  • Start date Start date
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
 
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
 
Thank You Chip

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


thanks again
BjShot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top