ssmith3156
New Member
- Joined
- Apr 11, 2023
- Messages
- 15
- Office Version
- 365
- Platform
- Windows
I need to write a VBA code multiplies the cells in columns J & K to return a result in column L, if the value in the cell of column H is L or O. For example: Since H21=L, then L21=J21*K21. The columns will never change, but the rows will change every month. This is what I have written, but it is not working.
Sub LaborCost()
'
' LaborCost Macro
' Enters formula to calculate cost for L and OT cost types.
'
'
Sheets("TOTAL COSTS").Select
Dim LastRow As Long
Dim i As Long
LastRow = Range("H" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Range("H" & i).Value = L Or Range("H" & i).Value = O Then
Range("L" & i).Value = PRODUCT("J" & i:"K" & i)
End If
Next i
Range("A2").Select
End Sub
Sub LaborCost()
'
' LaborCost Macro
' Enters formula to calculate cost for L and OT cost types.
'
'
Sheets("TOTAL COSTS").Select
Dim LastRow As Long
Dim i As Long
LastRow = Range("H" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Range("H" & i).Value = L Or Range("H" & i).Value = O Then
Range("L" & i).Value = PRODUCT("J" & i:"K" & i)
End If
Next i
Range("A2").Select
End Sub