|
|
|
date: Tue, 11 Mar 2008 12:00:49 +0100,
group: microsoft.public.word.vba.beginners
back
Re: How to reference an active cell
Hi Tomá¹,
If you want to colour all of the selected cells (even if they span more than one row):
Sub RowFormatter()
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End Sub
Alternatively, the following modification tells the macro to start in column 1 and stop at column 2 on the current row. You can
change the 1 & 2 to whatever you prefer.
Sub RowFormatter()
With Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 2)).Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End Sub
Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------
"Tomá¹ Vognar" <vognar(zavinac)esys.cz> wrote in message news:%23sb%23$uBhIHA.3788@TK2MSFTNGP03.phx.gbl...
> 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
>
>
> "macropod" <invalid@invalid.invalid> pí¹e v diskusním pøíspìvku news:eIDpGK3gIHA.3780@TK2MSFTNGP06.phx.gbl...
>> Hi Tomá¹,
>>
>> Try this:
>>
>> Sub RowFormatter()
>> With ActiveCell.EntireRow.Interior
>> .ColorIndex = 15
>> .Pattern = xlSolid
>> End With
>> End Sub
>>
>> Cheers
>> --
>> macropod
>> [MVP - Microsoft Word]
>> -------------------------
>>
>> "Tomá¹ Vognar" <vognar(zavinac)esys.cz> wrote in message news:efuAsc2gIHA.5280@TK2MSFTNGP04.phx.gbl...
>>> 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
>>>
>>> --
>>> Tomas Vognar
>>
>
date: Wed, 12 Mar 2008 23:10:42 +1100
author: macropod lid
|
|