Duplicate the rows above, With if, and an ever changing number of rows above

CVBASIMON

New Member
Joined
May 30, 2012
Messages
30
Here is the deal, in the first group of code (works fine) I copied over a column with a simple if statment. The amount in this column is ever changing. Now I am trying to copy this data and then paste it below with the opposite "40" or "50" for in the new if statement and code (In Red below) this is where i am getting hung up. Would anyone have another suggestion I could use on this? highlighted error comes across on the second to last line, highlighted in blue below.

Any suggestions would be greatly appreciated

Code:
FinalRow = Cells(Rows.Count, "G").End(xlUp).Row
Range("I2:I" & FinalRow).Formula = "=if(J2>0,40,50)"
Range("I2").Copy Destination:=Range("I" & FinalRow)
Range("I2").Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

Range("I2").Select
Cells(ActiveCell, ActiveCell.End(xlDown)).Select
Cells(FinalRow + 1, 9).Select
Cells(FinalRow + 1, 9).Formula = "=(if(I2=40,50,40)"
Selection(1, 9).Copy Destination:=(FinalRow + 1)
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I have been able to fiddle with it long enough to get the error out, however the formula shoes up in the cell after the last cell in the column. Meaning if I want this formula in cells I10 thru I20, it shows up in I21 and does not copy down. Anyone see my mistake in this? Can it be done?


Range("I2").Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Cells(FinalRow + 1, 9).Select
FinalRow = Cells(Rows.Count, "G").End(xlUp).Row
Cells(FinalRow + 1, 9).Formula = "=if(I2=40,50,40)"
Cells(1).Copy Destination:=Cells(FinalRow & 9)
 
Upvote 0

Forum statistics

Threads
1,211,680
Messages
6,103,250
Members
447,850
Latest member
thebuzzman15

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