Range

Orleans

New Member
Joined
Aug 10, 2011
Messages
2
I download data that has a different number of lines each download, but all are between 70,000 and 100,000 lines. I insert a column (C) then add (A)+(B) with the sum in the new column (C). My macro handles this well, but I then need to copy the new formula in (C) to the rest of the lines in column (C). Since each spreadsheet has a different number of lines, I can't figure out what to do in my macro stop copying the formula at the last line.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi and welcome to the board.

Here's how you can determine the last used row in a column. (In this case column A.)

Sub Demo()
Dim LstRw As Long
LstRw = Cells(Rows.Count, "A").End(xlUp).Row
MsgBox "The last row in column A with data in it is row " & LstRw
End Sub

Does that help?
 
Upvote 0
Try

Code:
Sub Cpy()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("C1:C" & LR).Formula = "=A1+B1"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,277
Members
452,902
Latest member
Knuddeluff

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