Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default adjustine the range of a selected cell

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,118
Default adjustine the range of a selected cell

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


"abumustapha" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default adjustine the range of a selected cell

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

"abumustapha" skrev i meddelelsen
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default adjustine the range of a selected cell

Try:

Sub Macro2()

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

End Sub

Good luck.

Ken
Norfolk, Va


On May 19, 2:41*pm, abumustapha
wrote:
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert selected cell value into next cell in range that is empty Guy[_2_] Excel Worksheet Functions 6 January 3rd 09 10:08 PM
Does the selected cell have a range name? Bill[_41_] Excel Programming 5 March 19th 07 08:02 PM
Determining Range of selected cell [email protected] Excel Programming 2 December 5th 06 06:49 AM
Referencing the First Cell in Any Selected Range maximouse Excel Programming 4 November 1st 05 03:57 AM
Macro run if and cell in range is selected in VBA Celtic_Avenger[_38_] Excel Programming 1 September 18th 04 04:51 PM


All times are GMT +1. The time now is 03:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"