Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Help coding a macro to detete blank rows and provide totals

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 182
Default Help coding a macro to detete blank rows and provide totals

Hi dread,

You can do this :

Sub Total()
Dim R As Range, TTL As Integer
For Each R In Range("B1:B50") ' change Range("B1:B50") to your range
If R.Value < "" And IsNumeric(R.Value) Then TTL = TTL + R.Value
Next R
MsgBox TTL
End Sub

--

Regards,

Halim


"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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Help coding a macro to detete blank rows and provide totals

I'm getting a compile error because i is not defined.

"Gary''s Student" wrote:

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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Help coding a macro to detete blank rows and provide totals

Hi Halim,

Instead of displaying the total in the MsgBox, how would I code this to
display the total in the first blank row?

Thanks.

"Halim" wrote:

Hi dread,

You can do this :

Sub Total()
Dim R As Range, TTL As Integer
For Each R In Range("B1:B50") ' change Range("B1:B50") to your range
If R.Value < "" And IsNumeric(R.Value) Then TTL = TTL + R.Value
Next R
MsgBox TTL
End Sub

--

Regards,

Halim


"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.

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
How does a function provide a blank cell as a result Rene B. Excel Worksheet Functions 2 June 1st 10 03:06 PM
how could i detete lots of rows by one commond Amit Mahar Excel Discussion (Misc queries) 1 May 15th 08 07:39 AM
Help: Macro Adds Rows, Need to Update Totals with New rows Matt[_39_] Excel Programming 2 August 7th 06 05:06 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM
KEEP blank rows when coding ranges vb noobie Excel Programming 2 May 19th 04 03:30 PM


All times are GMT +1. The time now is 11:45 PM.

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"