View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] lance.schaeffer@gmail.com is offline
external usenet poster
 
Posts: 10
Default Creating a custom formatting Macro

Alan,

Your sample code is exactly what I'm after - except is there a way to
do it so that instead of formatting MyCell cased on the condition, I
can format MyCellRow based on the condition? You will have to forgive
me, I am familiar with the concepts of VBA, but I am still very new to
VBA in Excel (I've done all my previous work in access).

Thanks for your help,

Lance
wrote:
Lance,

Based on info below, here's an example of code to format text as bold &
red based on each cell in a selected range. You have to change/add
format conditions as needed as well as resize the columns as needed.
Not sure how many conditions you are testing.

Alan

Sub TestData2()
Dim MyCell As Range
For Each MyCell In Selection
If Left(MyCell.Value, 2) = "a" Then
With MyCell.Resize(1, 10).Font
.Bold = True
.ColorIndex = 3
End With
End If
Next MyCell
End Sub

wrote:
Hello,

I am trying to create a macro that will custom format cells within a
range I have selected based on the contents of the cells. I get some
rather ugly output from a database in excel, and want to make it a bit
more readable (make specific rows different formats to show sub-totals
etc). All of my formatting will be based on the left-most cell (for
example, if the row starts with a *, then I want all of the data in the
range I select to be bold).

I would just use conditional formatting, but the end goal is to be able
to use this on any range of data quickly, conditional formatting cannot
be applied like that. I plan to make this so whenever I hit some key
combination yet to be decided it runs on my selected data and formats
as such.

Any ideas as to how I could go about doing this would be greatly
appreciated.

Lance