Highlighting a range of cells in VBA

B

brendang

Hi,

I was hoping someone might be able to help regarding the following
query.
I am trying to write a macro that will, among other things, select a
group of cells depending on the value of a named cell.

The type of thing I am going is as follows:




Sub Macro2()


-----------
s = Range("ROWCOUNT").Value (value of which is 5)
t = Range("ROWCOUNT").Value (value of which is 15)
Range("(A & s):(g & t)").Select


-----------
End Sub


This will give a runtime error 1004. Basically, I want to highlight
cells A5 to G15.

I would appreciate any help with this.
regards
Brendan.
 
D

Dick Kusleika

Brendan

Range("A" & s & ":G" & t).Select

Note that Range("ROWCOUNT").Value will not return both 5 and 15.
 

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

Top