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>
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I think you're just missing a period before the "Rows.Count"

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

Forum statistics

Threads
1,214,601
Messages
6,120,460
Members
448,965
Latest member
grijken

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