How to reference an active cell

T

Tomá¹ Vognar

I've recorded a simple macro for Excel, where I work with a row. But I want
to work with a row the active cell is on, but Macro Recorder has writen me
an absolute referencing. Should anyone help me, how to rewrite the code?

Sub Za¹edìní_øádku()
Range("A12:W12").Select !!!
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End Sub
 
B

Bob Phillips

Sub Za¹edìní_øádku()
With Activecell.Entirerow.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
T

Tomá¹ Vognar

Thank you very much, it works. But is it possible to rewrite it, so that
limited row was marked? (Since Ay to Wy, or using CurrentRegion)

T.Vognar
 
B

Bob Phillips

I am not understanding. Ay to Wy, what is that referring to?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
T

Tomá¹ Vognar

The best would be region defined by intersection of the CurrentRegion and
active line. I'm sorry, I'm trying this, but I get errors or wrong results.
I do not quite understand the syntax of the VBA, for the meantime.

T.Vognar


Bob Phillips said:
I am not understanding. Ay to Wy, what is that referring to?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)
 
J

JP

Sub Za¹edìní_øádku()
With Range("A12:W12").Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End Sub


--JP
 

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