Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Creating a custom formatting Macro

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Creating a custom formatting Macro

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Creating a custom formatting Macro

try using "EntireRow" ie.
MyCell.EntireRow.Interior.ColorIndex = 3 (or what ever format you'd
like to perform

Good luck,
Sandy

wrote:
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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Creating a custom formatting Macro

I realize my response was slightly deficient.

I'd like it to format the entire row, within the selection - I have
been able to make it do the entire row - but I'd like to not change the
format outside the selection

Sandy wrote:
try using "EntireRow" ie.
MyCell.EntireRow.Interior.ColorIndex = 3 (or what ever format you'd
like to perform

Good luck,
Sandy

wrote:
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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Creating a custom formatting Macro

Does this help???

Sub SelectionRowFormat()
Dim MyCell As Object
For Each MyCell In Selection
If MyCell = "3" Then

ActiveWindow.RangeSelection.Rows(MyCell.Row).Inter ior.ColorIndex = 3
End If
Next MyCell
End Sub


Sandy


wrote:
I realize my response was slightly deficient.

I'd like it to format the entire row, within the selection - I have
been able to make it do the entire row - but I'd like to not change the
format outside the selection

Sandy wrote:
try using "EntireRow" ie.
MyCell.EntireRow.Interior.ColorIndex = 3 (or what ever format you'd
like to perform

Good luck,
Sandy

wrote:
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


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
2003 - 2007 custom macro and custom button restore. Scott Sornberger Excel Discussion (Misc queries) 11 May 23rd 08 02:41 PM
Creating a custom formula axr0284 Excel Worksheet Functions 8 February 11th 08 12:25 PM
Creating a Macro For Shading Rows - Or Should I Use Conditional Formatting? [email protected] Excel Worksheet Functions 3 May 3rd 07 11:41 PM
expanding custom formatting without removing existing cell formatting? Keith Excel Worksheet Functions 3 December 27th 06 01:54 PM
Creating Macro Buttons and formatting Big H Excel Discussion (Misc queries) 0 November 1st 06 10:08 PM


All times are GMT +1. The time now is 11:54 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"