Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Formatting/Totalling Macro with varying rows of data

Fairly new to VBA, so I'm struggling with how to write a formatting macro for
an excel file. The file is automatically generated by Access with each report
run, but each report run could have a varying number of rows. How do I write
the formatting macro so that I can both format the columns/rows as needed and
put in the sum at the bottom of each data?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Formatting/Totalling Macro with varying rows of data

Hi,

Why don't you show us your code. Also, are the only thing that changes the
number of rows?

--
Cheers,
Shane Devenshire


"MSteckbeck" wrote:

Fairly new to VBA, so I'm struggling with how to write a formatting macro for
an excel file. The file is automatically generated by Access with each report
run, but each report run could have a varying number of rows. How do I write
the formatting macro so that I can both format the columns/rows as needed and
put in the sum at the bottom of each data?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Formatting/Totalling Macro with varying rows of data

This macro will place a SUM formula at the bottom of each column.

Number of rows and columns can be variable but assumes each column has same
number of rows or at least Column A is always longest column.

Sub Sumup22()
Dim rng As Range
Dim rng2 As Long
Dim rng1 As Range
Range("A1").Select
rng2 = Range("A1", Cells(ActiveCell.Row, Columns.Count) _
..End(xlToLeft)).Columns.Count
Set rng = Range("A1", Range("A" & Rows.Count). _
End(xlUp).Address)
Set rng1 = rng.Offset(rng.Rows.Count, 0).Resize(1, rng2)
rng1.Formula = Application.ConvertFormula _
("=Sum(" & rng.Address & ")", xlA1, xlA1, xlRelative)
End Sub

The formatting part will have be done by you unless you can specify what you
need.


Gord Dibben MS Excel MVP


On Tue, 5 Feb 2008 11:14:01 -0800, MSteckbeck
wrote:

Fairly new to VBA, so I'm struggling with how to write a formatting macro for
an excel file. The file is automatically generated by Access with each report
run, but each report run could have a varying number of rows. How do I write
the formatting macro so that I can both format the columns/rows as needed and
put in the sum at the bottom of each data?


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
Using macro/vba to copy varying ranges of rows BCLivell Excel Discussion (Misc queries) 3 June 6th 07 02:52 PM
Copying cells from varying rows annettek Excel Discussion (Misc queries) 2 May 25th 07 02:51 PM
Alternating shading of varying groups of rows AntDawg Excel Discussion (Misc queries) 3 July 16th 06 11:02 PM
SUMPRODUCT with varying # of rows Ren Excel Worksheet Functions 5 June 27th 06 11:28 PM
Totalling rows Muruk Excel Worksheet Functions 11 December 1st 04 06:09 AM


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