View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Help coding a macro to detete blank rows and provide totals

Sub dread()
Dim r As Range, rr As Range
Set r = ActiveSheet.UsedRange
Dim l As Long, k As Long
l = r.Rows.Count + r.Row

For k = 1 To l
Set rr = Range(Cells(k, 1), Cells(k, 256))
If Application.CountA(rr) = 0 Then
Exit For
End If
Next


For i = 1 To 256
Cells(k, i).Value = 0
For kk = 1 To k - 1
Cells(k, i).Value = Cells(k, i).Value + Cells(kk, i).Value
Next
Next
End Sub

Will locate the first empty row and then fill that row with the sum of the
rows above it.
--
Gary''s Student


"dread" wrote:

I have a macro that copies information from several worksheets into one
worksheet. After the information is copied the macro sorts the new worksheet
so that blank rows are moved to the end. I want to code the macro to also
find the first blank row (after the copied data) and give me totals. How do
I do this?

Thank you.