Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Liz Liz is offline
external usenet poster
 
Posts: 133
Default VBA dynamically format Row1

Hello All -

Thanks in advance for any help. Background info: Excel 2003 Sp1

I am trying to create a macro\subroutine to format the first row in a
spreadsheet. Of course I can get the formatting syntax by recording a macro
as I format. The problem is dynamically identifying the last column used. I'd
like to use this macro for all of my spreadsheets so the number of columns
will vary.

For example;
spreadsheet1
A1=FirstName
B1=LastName
C1=SS#

spreadsheet2
A1=Category
B1=SubCategory

So running the macro in either spreadsheet would set the background to gray,
bold, horizontal, wordwrap, etc just for the columns that contain data. In
spreadsheet 1 that would be 3 cells (A1,B1,C1) and spreadsheet 2 2
cells(A1,B1).

If you can provide a snip-it of code that would be appreciated.

Thanks in advance,
Liz
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA dynamically format Row1


Set rng = Range("A1").Resize(,Cells(1,Columns.Count).End(xlT oLeft).Column)

then just format using the variable rng object.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Liz" wrote in message
...
Hello All -

Thanks in advance for any help. Background info: Excel 2003 Sp1

I am trying to create a macro\subroutine to format the first row in a
spreadsheet. Of course I can get the formatting syntax by recording a

macro
as I format. The problem is dynamically identifying the last column used.

I'd
like to use this macro for all of my spreadsheets so the number of columns
will vary.

For example;
spreadsheet1
A1=FirstName
B1=LastName
C1=SS#

spreadsheet2
A1=Category
B1=SubCategory

So running the macro in either spreadsheet would set the background to

gray,
bold, horizontal, wordwrap, etc just for the columns that contain data.

In
spreadsheet 1 that would be 3 cells (A1,B1,C1) and spreadsheet 2 2
cells(A1,B1).

If you can provide a snip-it of code that would be appreciated.

Thanks in advance,
Liz



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA dynamically format Row1

Thanks in advance for any help. Background info: Excel 2003 Sp1

I am trying to create a macro\subroutine to format the first row in a
spreadsheet. Of course I can get the formatting syntax by recording a
macro
as I format. The problem is dynamically identifying the last column used.
I'd
like to use this macro for all of my spreadsheets so the number of columns
will vary.

-------------
LastCol = ActiveSheet.Cells(1,
Application.Columns.Count).End(xlToLeft).Column


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
Dynamically update label axis *format* without VBA? (03 and 07) ker_01 Charts and Charting in Excel 6 March 17th 10 11:59 PM
How to change the row1 content of the existing excel file automically tlee Excel Worksheet Functions 2 April 28th 09 01:47 AM
How to get row2 value into row1 in calculated Field Column in pivo arun Excel Discussion (Misc queries) 0 March 31st 09 08:50 AM
Is It Possible To Dynamically Name Series? MJ Charts and Charting in Excel 1 July 29th 08 06:49 PM
Sum columns dynamically Delboy Excel Worksheet Functions 1 July 28th 06 03:33 PM


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