VBA to multiply column by two different amounts based on date

Andrewk1

New Member
Joined
Jan 15, 2015
Messages
4
I hope someone can help with this. I can't find anything on the web to help and everything I have tried fails.
I need to multiply the figures in column L by 50 if the date in column A was before 01/04/2018 otherwise multiply it by 60.
Here is the existing code which I was using prior to 01/04/2018 when I only needed to multiply column L by 50.

Sub test50_HourlyRate()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim Lastrow As Long
With Worksheets("Timemaster data")
Range("R:S").NumberFormat = "£#,##0.00"
Range("R3").Formula = "=L3*50"
Lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("R3").AutoFill Destination:=.Range("R3:R" & Lastrow) _
, Type:=xlFillDefault
Range("S3").Formula = "=INDEX(Rates!$B:$B,MATCH($B3,Rates!$A:$A,0))*L3"
Lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("S3").AutoFill Destination:=.Range("S3:S" & Lastrow) _
, Type:=xlFillDefault
End With
Sheets("Timemaster data").Calculate
Sheets("Timemaster data").Activate
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues


Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Thanks for the reply, but this piece of code is part of a much bigger macro and I really need to do it with VBA.
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,157
Members
452,615
Latest member
bogeys2birdies

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