Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
TD
 
Posts: n/a
Default How do I have a macro format cells while recording?

I am attempting to record a macro similar to the one below, however at the
end of the data/sort I want to include cell formatting so that the top three
automatically appear in green, and the fourth automatically appears in red.
Is this possible?

Range("A4:H15").Select
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Set rng = Range("A4:H15")
rng.Sort Key1:=rng.Cells(1,1),Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
rng.cells.Interior.Colorindex = xlColorindexNone
For each cell in rng
If cell.Value = Application.Small(rng,1) Or cell.Value =
Application.Small(rng,2) Or _
cell.Value = Application.Small(rng,3) Then
cell.Interior.Colorindex = 10
ElseIf cell.Value = Application.Small(rng,4)Then
cell.Interior.Colorindex = 3
End If
Next cell

End Sub

--
HTH

Bob Phillips

"TD" wrote in message
...
I am attempting to record a macro similar to the one below, however at the
end of the data/sort I want to include cell formatting so that the top

three
automatically appear in green, and the fourth automatically appears in

red.
Is this possible?

Range("A4:H15").Select
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending,

Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub



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
How do I format cells and enter data to be valued for TIME and th. George Excel Worksheet Functions 1 April 11th 05 07:23 PM
format cells Alfred Excel Worksheet Functions 2 April 1st 05 03:43 PM
Format Macro Buttons? Ken Excel Discussion (Misc queries) 5 March 2nd 05 08:40 PM
My sheet is unprotected, but I can't format cells. Paul Excel Discussion (Misc queries) 2 February 9th 05 11:20 PM
Protected cells -automatically format to a different color Fred Evans Excel Discussion (Misc queries) 9 December 3rd 04 12:59 PM


All times are GMT +1. The time now is 04:01 PM.

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"