Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Formatting Macro using rowcount

Pretty sure this is straight forward but not quite sure which vba
function is best for this task but essentially I want to format a
sheet of data that has a fixed number of columns but a variable number
of rows.

Therefore I need a macros that can count the number of populated rows
in the first column then to simply apply a grid overlay and set the
print area to that last row, any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Formatting Macro using rowcount

You can get the row number of the last row containing any data (no matter
what column that data is in) using this...

LastUsedRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row

--
Rick (MVP - Excel)


wrote in message
...
Pretty sure this is straight forward but not quite sure which vba
function is best for this task but essentially I want to format a
sheet of data that has a fixed number of columns but a variable number
of rows.

Therefore I need a macros that can count the number of populated rows
in the first column then to simply apply a grid overlay and set the
print area to that last row, any ideas?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Formatting Macro using rowcount

Any blank rows or columns?

If not, setting the current region should work.

Dim rng As Range
Set rng = Cells(1).CurrentRegion
do stuff with rng


Gord Dibben MS Excel MVP


On Mon, 16 Mar 2009 13:45:32 -0700 (PDT), "
wrote:

Pretty sure this is straight forward but not quite sure which vba
function is best for this task but essentially I want to format a
sheet of data that has a fixed number of columns but a variable number
of rows.

Therefore I need a macros that can count the number of populated rows
in the first column then to simply apply a grid overlay and set the
print area to that last row, any ideas?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Formatting Macro using rowcount

Dim myRng As Range

With Worksheets("Sheet99") 'sheet name changed here
'I'm using columns A:X and the last row in column A
Set myRng = .Range("a1:x" & .Cells(.Rows.Count, "A").End(xlUp).Row)
.PageSetup.PrintArea = myRng.Address(external:=True)
End With

There are tons of ways to apply that border formatting. I'd record a macro the
way I wanted (border styles, colors, weights, ...) and then apply it the myRng
range object.

If you need help with that, post back with your recorded code.

I'm sure you'll get lots of help.

" wrote:

Pretty sure this is straight forward but not quite sure which vba
function is best for this task but essentially I want to format a
sheet of data that has a fixed number of columns but a variable number
of rows.

Therefore I need a macros that can count the number of populated rows
in the first column then to simply apply a grid overlay and set the
print area to that last row, any ideas?


--

Dave Peterson
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 macro help [email protected] Excel Discussion (Misc queries) 2 March 10th 09 12:53 PM
Formatting using Macro simplymidori[_2_] Excel Discussion (Misc queries) 4 April 11th 08 12:22 AM
formatting a macro Maggie Excel Programming 2 February 28th 07 09:07 PM
Formatting via a macro mike_vr Excel Discussion (Misc queries) 3 November 8th 06 04:19 PM
Macro Formatting? Please Help Plasmaticfire[_2_] Excel Programming 1 August 11th 06 08:00 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"