Help with copy past under blank row.

Harley78

Active Member
Joined
Sep 27, 2007
Messages
372
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I am trying to figure out how to copy and paste formulas in column G & H starting on row 11. I currently copy and paste G7, H7 & G8, H8 manual down the list in those that have two or more rows, then double click so it populates down to the end of that section (Accumulative for that section). Then i go back and copy and paste G7 & H7 manually to those that contain only one line.

I have a macro that inserts blank rows (command button) between different part numbers (based on column A). Just wanted to see if there is a way i can do the above.

Is there a possibility? Any help or direction is appreciated

Thanks a bunch

Bill


Example:

Part Number Planner ICU REQ Stock Start time INV INV
after plus
after plus

build rec
A B C D E F G H
7 1-2-3-4 CD2 9-8-7-6 454 8767 08.07.2013 19:18:02 8,313 8,313 (G7 FORMULA = =E7-D7) (H7 FORMULA = =G7+(I7+J7+K7+L7+M7+N7+O7+P7+Q7+R7)
8 1-2-3-4 CD2 9-8-7-6 1176 09.07.2013 10:18:51 7,137 7,137 (G8 FORMULA = =H7-D8) (H8 FORMULA = =G8+(I8+J8+K8+L8+M8+N8+O8+P8+Q8+R8)
9
10
11 1-2-3-4 CG1 9-8-7-6 1511 1774 16.04.2018 01:35:23 =E11-D11 =G11+(I11+J11+K11+L11+M11+N11+O11+P11+Q11+R11)
12 1-2-3-4 CG1 9-8-7-6 301 1774 18.04.2018 11:17:23 =H12-D12 =G12+(I12+J12+K12+L12+M12+N12+O12+P12+Q12+R12)
13 1-2-3-4 CG1 9-8-7-6 166 1774 18.04.2018 12:49:50
14
15 1-2-3-5 CG1 9-8-7-5 667 1774 18.04.2018 22:11:12 =E15-D15 =G15+(I15+J15+K15+L15+M15+N15+O15+P15+Q15+R15)
16
17 1-2-3-6 CG1 9-8-7-4 62 1774 19.04.2018 12:41:36 =E17-D17 =G17+(I17+J17+K17+L17+M17+N17+O17+P17+Q17+R17)
18 1-2-3-6 CG1 9-8-7-4 40 1774 19.04.2018 14:02:03 =H18-D18 =G18+(I18+J18+K18+L18+M18+N18+O18+P18+Q18+R18)
19 1-2-3-6 CG1 9-8-7-4 1332 1774 23.04.2018 04:05:51
20 1-2-3-6 CG1 9-8-7-4 104 1774 23.04.2018 15:23:37
21 1-2-3-6 CG1 9-8-7-4 80 1774 23.04.2018 15:47:09
22
23 1-2-3-7 CG1 9-8-7-3 298 1774 23.04.2018 16:05:59
24
25 1-2-3-8 CG1 9-8-7-2 361 345 17.04.2018 12:44:57
26 1-2-3-9 CG1 9-8-7-3 478 345 18.04.2018 07:15:08
27 1-2-3-9 CG1 9-8-7-4 172 345 19.04.2018 10:54:35
28 1-2-3-9 CG1 9-8-7-5 14 536 14.04.2018 01:59:43
29 1-2-3-9 CG1 9-8-7-6 129 536 17.04.2018 16:19:23
30 1-2-3-9 CG1 9-8-7-7 294 536 23.04.2018 03:03:44
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Sorry, just tested it and yes, it works like a charm! Thank you so very much!
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0
Hello Fluff,

I am going through the code and wanting to learn what each line does and making notes. I do have a question. What line determines start cell for copying the formula. Example, i deleted rows that weren't necessary, leaving only the 4 cells with formulas for copy paste. When selecting copy formula it starts on line 14 and not 12 which does have line? Oh did add columns as you can see below. I did understand the lines up to why it isn't starting on line 12. Helpless I know :)



Excel Workbook
ABCDEFGHIJ
1ECUComponent describtionPlannerICUProduct Short DescriptionREQStockStart timeINVINV
2afterplus
3afterplus
4
5buildrec
6
700
800
9
10
11
1206-2109-7409-3-00EBS ER100 NIS X60A MY14 ESC MEX PYACD206-2102-3466-4-97HECU HW-EDM MK100 ESC PYA NISSAN X60A12866823.04.2018 07:34:50
13
1406-2109-7856-3-00EBS ER100 MAZ J36W MY14 ESCCD206-2102-4220-4-12ICU Assy. Mazda J36W MK100 ESC Base 20151014123.04.2018 07:14:13131131
15
1606-2109-7949-3-00EBS ER100 MAZ J36A MY16 ESC 16CYCD206-2102-4456-4-12HECU MK100 ESC HW-EDM MAZ J36A MY16740333820.04.2018 06:03:012,5982,598
1706-2109-7949-3-00EBS ER100 MAZ J36A MY16 ESC 16CYCD206-2102-4456-4-12HECU MK100 ESC HW-EDM MAZ J36A MY16756333825.04.2018 13:35:451,8421,842
18
1906-2109-7999-3-00EBS ER100 MAZ J03A MY16 ESC IPM2 16CYCD206-2102-4581-4-12HW-EDM HYDR.ELECTR CONTR UNIT MK100 ESC735229719.04.2018 20:24:251,5621,562
20
2106-2109-8082-3-00EBS ER100 MAZ J03W MY16 ESCCD206-2102-4668-4-12HW-EDM HECU MK100 ESC DSC Mazda J03W '1655613820.04.2018 02:14:40(418)(418)
2206-2109-8082-3-00EBS ER100 MAZ J03W MY16 ESCCD206-2102-4669-4-12HW-EDM HECU MK100 ESC DSC Mazda J03W '1655113820.04.2018 03:24:23(969)(969)
23
Demand Worksheet (2)
 
Upvote 0
Code:
Sub CopyFormula()
         Dim i As Long, j As Long
         Dim Ar As Areas
1        With Range("H7", Range("H" & Rows.count).End(xlUp)).SpecialCells(xlConstants)
2           Set Ar = .Areas
3           For i = 2 To Ar.count
4              Ar(i).Offset(, 1).Resize(1, 2).FormulaR1C1 = Range("I7:J7").FormulaR1C1
5              For j = 1 To Ar(i).count - 1
6                 Ar(i)(j).Offset(1, 1).Resize(1, 2).FormulaR1C1 = Range("I8:J8").FormulaR1C1
7              Next j
8           Next i
9        End With
End Sub
2) sets AR to each non contiguous area (range) in col H (in this case $H$12,$H$14,$H$16:$H$17,$H$19,$H$21:$H$22)
3) loops through the Areas starting at 2 (ie H14)
4) when i=3 then this line is effectively range("I16:J16").formulaR1C1=
5) loops through each range in the area
6) inserts the 2nd formula for each row in the area starting on the 2nd row

Originally you had data in H7:H8 which would have been the 1st area (ie AR(1)), but as there was the original formula in those rows, the code starts in AR(2).
Now you have removed that data you need the code to start with AR(1), so change
Code:
For i = 2 To Ar.count
this to i=1
 
Upvote 0
Again, many thanks and most of the lines I got and now confirmed. Thanks for the change and that helped and worked.
 
Upvote 0

Forum statistics

Threads
1,224,804
Messages
6,181,059
Members
453,016
Latest member
cherryfalling

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top