View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Current Selected Range

Sub test()

Dim rng As Range

Set rng = Selection

rng.Interior.ColorIndex = 3

End Sub

You can do it directly on Selection as well, without setting a range.

RBS

"infojmac" wrote in
message ...

Hi,

I'm sure this is so simple - but i cant get my head round it!

All i want is the macro to run on the current selected range (just
format some cells) but i dont want any message boxes the user just
highlights the range and then hits the macro key.

Sub FormatCells()

Dim myRange As Range
Set myRange = ActiveCell.Selection (tried ActiveSheet.Selection and
varoius others but to no avail!)

myRange.Interior.Color = vbBlue
'etc

End Sub

Wondered if anyone could provide some help

Thanks


--
infojmac
------------------------------------------------------------------------
infojmac's Profile:
http://www.excelforum.com/member.php...o&userid=10787
View this thread: http://www.excelforum.com/showthread...hreadid=561776