my first macro

  • Thread starter Thread starter DALE
  • Start date Start date
D

DALE

I am experimenting with my first macros, so excuse my ignorance. I
want to create a calculated column of data and a total. I want the
macro to work no matter how many rows of data are in the sheet. Seems
that when I create the macro using absolute or relative I get the same
result, the marco only works for the exact number of rows when I
recorded it... any suggestions?

Dale
 
Dale

This macro will add a total formula at the cell below your used range in
column B.

Sub SumupB()
Dim Rng As Range
Set Rng = Range("B1", Range("B" & Rows.Count). _
End(xlUp).Address)
Set rng1 = Rng.Offset(Rng.Rows.Count, 0).Resize(1, 1)
rng1.Formula = "=Sum(" & Rng.Address & ")"
End Sub

As for the Macro Recorder and relative/absolute recording.......it just
doesn't quite do the job expected but should give you an idea.

For a few examples of how to translate the Macro Recorder code and spruce it
up see Tushar Mehta's site. Scroll down to VBA "Beyond the Macro Recorder".

http://www.tushar-mehta.com/

Gord Dibben Excel MVP XL2002
 
Back
Top