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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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,384
Messages
6,119,201
Members
448,874
Latest member
Lancelots

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