LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default VBA Code to calculate SUM and COPY&PASTE cell value in inserte

Jacob,

thank you so much - I really appreciate it. It works perfectly

Thanks Bob and Joel for your input as well, I appreciate the assistance

regards

"Jacob Skaria" wrote:

Modified your code to suit the requirement....

Sub test()
firstrow = 2 'set to your first data row
lastrow = 300 'set or caclulate lat data row
datecolumn = 9 'assign as necessary
checkrow = firstrow
While checkrow < lastrow
If Cells(checkrow, datecolumn) < Cells(checkrow + 1, datecolumn) Then
Rows(checkrow + 1).EntireRow.Insert
Range("F" & checkrow + 1).Formula = _
"=SUM(F" & firstrow & ":F" & checkrow & ")"
Range("H" & checkrow + 1).Formula = _
"=SUM(H" & firstrow & ":H" & checkrow & ")"
Range("I" & checkrow + 1) = Range("I" & checkrow)
firstrow = checkrow + 2
checkrow = checkrow + 2
lastrow = lastrow + 1
Else: checkrow = checkrow + 1
End If
Wend
End Sub

--
Jacob


"PVANS" wrote:

Good morning,

I hope someone can assist me with this (btw, if this is a duplicate of a
post I just made, apologies... my IE browser said that an issue had occured,
and I don't believe it did post)

I have the following code to insert a line after groups (of 2 rows usually*):
Sub test()
firstrow = 2 'set to your first data row
lastrow = 300 'set or caclulate lat data row
datecolumn = 9 'assign as necessary
checkrow = firstrow
While checkrow < lastrow
If Cells(checkrow, datecolumn) < Cells(checkrow + 1, datecolumn) Then
Rows(checkrow + 1).EntireRow.Insert
checkrow = checkrow + 2
lastrow = lastrow + 1
Else: checkrow = checkrow + 1
End If
Wend
End Sub

However, what I need now (and can't work out at all), is for the following
to occur within that inserted blank line:
in column 6 - sum of grouped rows above
in column 8 - sum of grouped rows above
in column 9 - copy text that is in row above

Example:
1 2 3 4 5 6 7 8 9
x x x x x 1 x 2 y
x x x x x 3 x 4 y
4 6 y

Please if someone can help me add this extra requirement into my code (or
have a new module to do this) I would be so grateful.

Thanks in advance,

Kind regards,
Paul



 
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
Need code to copy and paste based on cell address. GoBow777 Excel Discussion (Misc queries) 1 July 13th 08 07:24 AM
Calculate,Copy, Paste Cell Group Macro Adjustments [email protected] Excel Programming 2 March 1st 06 03:49 AM
Calculate,Copy, Paste Cell Group [email protected] Excel Programming 7 February 24th 06 01:32 AM
Copy from one worksheet to another is inserted into wrong cell Markus F. Robinson Excel Discussion (Misc queries) 0 January 22nd 06 09:31 PM
Calculate, Copy, Paste [email protected] Excel Programming 6 November 16th 05 01:44 PM


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