Formula going way past Final Row

CVBASIMON

New Member
Joined
May 30, 2012
Messages
30
Hi ALL,

I am having difficulty wtih an if statement going about 100 rows paste the final row, it seems each time i run the macro it goes further paste the last. Which makes me feel like I have a double of something, any help would be great, below is he current code.

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

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Does column C contain formulas that might be returning "" ?

Make sure this line is reffering to a column that contains constants, not results of formulas.
FinalRow = Cells(Rows.Count, "C").End(xlUp).Row
 
Upvote 0
Does column C contain formulas that might be returning "" ?

Make sure this line is reffering to a column that contains constants, not results of formulas.
FinalRow = Cells(Rows.Count, "C").End(xlUp).Row



That is what makes it even funnier, I am using Column C as another FinalRow = Cells(Rows, Count, "C").End(xlup).row

Do I need to use another one?
 
Upvote 0
hello
change to this


Range("I2:I" & FinalRow).Formula = "=if(J2>0,""40"",""50"")"
Range("I2").Copy Destination:=Range("I" & FinalRow)

cheers
 
Upvote 0
hello
change to this


Range("I2:I" & FinalRow).Formula = "=if(J2>0,""40"",""50"")"
Range("I2").Copy Destination:=Range("I" & FinalRow)

cheers


Thank you! Perfect! ....amazing how some of you guys are able to pick this stuff up and see it so quickly.
 
Upvote 0
Good eyes, I didn't catch that...
hello
change to this


Range("I2:I" & FinalRow).Formula = "=if(J2>0,""40"",""50"")"
Range("I2").Copy Destination:=Range("I" & FinalRow)
cheers

I'm also wondering why the quotes around 40 and 50..
If you want those to be numerical values, there should not be quotes there.

Perhaps
Code:
With Range("I2:I" & FinalRow)
    .Formula = "=if(J2>0,40,50)"
    .Value = .Value
End With
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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