Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default formatting macro help

Hi,

I have a report that has a different number of columns each day. I
have the macro highlighting rows, 2 highlighted, 2 blank. But I only
want the highlighting to extend to x number of columns. One problem
is each data set has blanks in it, so I can't use the EndxlToRight for
every row. I need to replace the "Z" in the statement Range("A1:Z2")
with the x variable.
Can you please help?


Dim x As Long
Range("A4").Select
Range(Selection, Selection.End(xlToRight)).Select
x = Selection.Columns.Count
Range("A1").Select
Do
ActiveCell.Offset(4, 0).Range("A1:Z2").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
Loop Until ActiveCell.Offset(4, 0) = ""

Thanks!
Bret
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default formatting macro help

You could use
x =Cells(4,Columns.Count).End(xlToLeft).Column

or, better, in case row 4 is missing something in the last column

x = Range("A4").CurrentRegion.Columns.Count

And use

Do
ActiveCell.Offset(4, 0).Resize(1,x).Select

to incorporate x into your formatting routine.


HTH,
Bernie
MS Excel MVP


wrote in message
...
Hi,

I have a report that has a different number of columns each day. I
have the macro highlighting rows, 2 highlighted, 2 blank. But I only
want the highlighting to extend to x number of columns. One problem
is each data set has blanks in it, so I can't use the EndxlToRight for
every row. I need to replace the "Z" in the statement Range("A1:Z2")
with the x variable.
Can you please help?


Dim x As Long
Range("A4").Select
Range(Selection, Selection.End(xlToRight)).Select
x = Selection.Columns.Count
Range("A1").Select
Do
ActiveCell.Offset(4, 0).Range("A1:Z2").Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
Loop Until ActiveCell.Offset(4, 0) = ""

Thanks!
Bret



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default formatting macro help

On Mar 10, 8:35*am, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
You could use
x =Cells(4,Columns.Count).End(xlToLeft).Column

or, better, in case row 4 is missing something in the last column

x = Range("A4").CurrentRegion.Columns.Count

And use

*Do
* *ActiveCell.Offset(4, 0).Resize(1,x).Select

to incorporate x into your formatting routine.

HTH,
Bernie
MS Excel MVP

wrote in message

...

Hi,


I have a report that has a different number of columns each day. *I
have the macro highlighting rows, 2 highlighted, 2 blank. *But I only
want the highlighting to extend to x number of columns. *One problem
is each data set has blanks in it, so I can't use the EndxlToRight for
every row. *I need to replace the "Z" in the statement Range("A1:Z2")
with the x variable.
Can you please help?


Dim x As Long
* *Range("A4").Select
* *Range(Selection, Selection.End(xlToRight)).Select
* *x = Selection.Columns.Count
* *Range("A1").Select
* *Do
* *ActiveCell.Offset(4, 0).Range("A1:Z2").Select
* *With Selection.Interior
* * * *.ColorIndex = 15
* * * *.Pattern = xlSolid
* *End With
* *Loop Until ActiveCell.Offset(4, 0) = ""


Thanks!
Bret


Works perfect. Thanks!
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
Formatting using Macro simplymidori[_2_] Excel Discussion (Misc queries) 4 April 11th 08 12:22 AM
Formatting for a Macro Maggie Excel Discussion (Misc queries) 3 February 28th 07 02:00 AM
Formatting via a macro mike_vr Excel Discussion (Misc queries) 3 November 8th 06 04:19 PM
Conditional Formatting in Macro shantanu oak Excel Discussion (Misc queries) 2 July 14th 06 01:11 PM
Date Formatting in a Macro [email protected] Excel Discussion (Misc queries) 3 May 19th 06 02:09 AM


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