Getting subtraction element to work on the final row rather than only the first

jarnold231

New Member
Joined
Jul 20, 2012
Messages
2
Hello all,

I'm having trouble getting the subtraction element of this code to work on the final row of data each time it is run instead of only on the specific cells which are referenced in the code. I've tried using

Dim lrb As Long
With Sheets ("________")
lrb = .Range ("F" & Rows.Count) .End(3).Row

But this doesnt seem to help.

Any ideas greatly appreciated.


<code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-style: inherit; font-weight: inherit; font-family: monospace; line-height: 12px; ">Sub SubtractionElement()Dim lrb As LongWith Sheets("_________") lrb = .Range("F" & Rows.Count).End(3).RowSheets("____________").Range("F2").Copy .Range("B" & lrb + 1)Application.Run "Copy______Data"Dim x As Double x = CDbl(Worksheets("________").Cells(2, 3).Value) - CDbl(Worksheets("_________").Cells(2, 2).Value) Worksheets("_________").Cells(2, 3).Value = xEnd WithEnd Sub</code></pre>
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

memar_one

Board Regular
Joined
Jul 20, 2012
Messages
161
I think you're just missing a period before the "Rows.Count"

lrb = .Range("F" & .Rows.Count).End(xlUp).Row</pre>
 

Watch MrExcel Video

Forum statistics

Threads
1,122,224
Messages
5,594,914
Members
413,952
Latest member
JGer

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
Top