LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Insert a Row and then Sum

I have a problem. I have a large set of data whose first column downloads a
manufactured part that is tied to a list of attributes. For example the
first 10 rows in column 1 are all the same number, e.g. 12345 and then the
each row in column 2, 1 thru 10 is a different numbered attribute such as Row
1 Column 2 is 890 and Row 2 Column 2 is 899, etc. After the initial 10 rows
it starts with another manufacturers part that might go for 20 rows, etc. I
want to insert two blank rows and sum the 10 rows in Column 2, and then the
next X rows for the next part number. I thought I had it figured out with
the below macro, but for some reason after the rows are inserted I run the
sum macro and it stops at row 4,460 even though I have more data to sum. I
scrubbed the data to see if it is an anomolly with the row or the data in
that cell but there doesn't seem to be a problem with it. Here are my
macros: Can someone help me out or explain why it's stopping at row 4,460?

Sub SumAndSeparate()
StartRow = 2 'Change the 2 to the row actual data start
DataColumn = 1 'Change the 1 to the column where your data is

i = StartRow + 1
While Cells(i, DataColumn) < ""
If Cells(i, DataColumn) < Cells(i - 1, DataColumn) Then
Cells(i, DataColumn).EntireRow.Insert
Cells(i, DataColumn).EntireRow.Insert ' a 2nd blank row added
i = i + 2
End If
i = i + 1
Wend

End Sub
Sub insert_sum_values()
Dim sum_of_range, tmp

For i = 1 To 32

If i = 1 Or i = 11 Or i = 16 Or i = 17 Or i = 18 Or i = 19 Or i = 20
Or i = 21 Or i = 22 Or i = 23 Or i = 24 Or i = 25 Or i = 26 Or i = 27 Or i =
28 Or i = 29 Or i = 30 Or i = 31 Or 32 Then
'column numbers where sums required
Cells(3, i).Select
'first cell at top of range to be summed

Do
Range(ActiveCell, ActiveCell.End(xlDown)).Select
tmp = ActiveCell.Value
If tmp < "" Then
sum_of_range = "=SUM(" & Selection.Address & ")"
ActiveCell.End(xlDown).Offset(1, 0).Value = sum_of_range
ActiveCell.End(xlDown).Offset(2, 0).Select
Else
sum_of_range = ""
End If
Loop Until sum_of_range = ""
End If
Next i
End Sub



 
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
Cannot insert worksheet in exel - not available in insert menu pedro39 Excel Worksheet Functions 1 July 24th 08 12:09 PM
insert row / insert column command buttons fairgreen Excel Worksheet Functions 1 October 29th 07 02:41 PM
How can I insert a date with an icon (calendar) insert Alfredo Mederico[_2_] Excel Discussion (Misc queries) 4 September 21st 07 01:20 AM
Can I auto insert a worksheet when I insert a value in a cell. iainc Excel Worksheet Functions 0 April 27th 06 08:37 AM
Insert Next? Or insert a variable number of records...how? Tom MacKay Excel Discussion (Misc queries) 0 April 20th 06 10:44 PM


All times are GMT +1. The time now is 05:54 AM.

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"