How to integrate Lastrow in Formula in VBA

knaabis

Active Member
Joined
Apr 25, 2006
Messages
254
Office Version
  1. 2013
Platform
  1. Windows
i have calculation like this:
SpecifikacijaTest1.xls
ABCDE
18=A1*E12
27=A2*E13
34=A3*E1
43=A4*E2
56=A5*E2
65=A6*E2
CutList

In first step macros appears result in column A in Rows 1, 2, 3 - then next calculation is A1, A2, A3 multiply with E1.
Second macros appears result in Column A in Rows 4, 5, 6 - then next calculation will be - macros check last row in Column B and make calculation with Column A&Lastrow+1 and with E3.
That i mean A4, A5, A6 multiply with E3.
I have Macros like this, but it not work...

Sub Test()
Dim Sh As Worksheet
Dim Rng As Range
Set Sh = ActiveSheet
lastrow = Range("b1").End(xlDown).Row
With Sh
Set Rng = .Range("b" & lastrow + 1 & ":b100")
End With
With Rng
.Formula = "= A & (Lastrow + 1) * $E$2 "
.Value = .Value
End With
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
does this work?
Code:
With Rng
    .Formula = "= A" & LastRow + 1 & "*$E$2"
    .Value = .Value
End With
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

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