adjustine the range of a selected cell

A

abumustapha

Hi there,
I have written the following macro to change the color of a cell as
selected. I am trying to adjust the macro where it will automatically add
(6)cells to the right of the selected cell and apply the same format.

the Macro is:

Sub Macro2()
ActiveSheet.Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
Range("A1").Select
End Sub

Your help is greatly appriciated
 
R

Ron Coderre

Try something like this:

Sub PaintMeAndSixCellsRight()
With ActiveCell.Resize(Columnsize:=7).Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
Range("A1").Select
End Sub


Is that something you can work with?
Post back if you have more questions.

Regards,

Ron
Microsoft MVP - Excel
 
P

Per Jessen

Hi

Look at this

Sub Macro2()
ActiveSheet.Select
aCell = Selection.Address
Range(aCell, Range(aCell).Offset(0, 6)).Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
Range("A1").Select
End Sub

Regards,
Per
 
K

Ken

Try:

Sub Macro2()

With Selection.Resize(1, 6).Interior
.ColorIndex = 40
.Pattern = xlSolid
End With

End Sub

Good luck.

Ken
Norfolk, Va
 

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