Hi Everyone,
Beginner with VBA here. I'm having trouble with a simple macro I'm writing. Everything works as expected except I get errors whether using PasteSpecial(xlPasteValues). I've tried worksheets.range and worksheets.cells. Is it because I'm using Cut rather than Copy?
Thanks.
Beginner with VBA here. I'm having trouble with a simple macro I'm writing. Everything works as expected except I get errors whether using PasteSpecial(xlPasteValues). I've tried worksheets.range and worksheets.cells. Is it because I'm using Cut rather than Copy?
Thanks.
Code:
Dim lRow As Long, lCol As Long, lMax As Long
'Add new row to Ledger
Worksheets("Ledger").ListObjects("tbl_ledger").ListRows.Add
'Find first empty row in Ledger
For lCol = 1 To 3
lRow = Worksheets("Ledger").Cells(Rows.Count, lCol).End(xlUp).Row
If lRow > lMax Then lMax = (lRow - 1)
Next lCol
'Copy input from Dashboard Input Fields to next empty row in Ledger
Worksheets("Dashboard").Range("B2:D2").Cut Worksheets("Ledger").Cells((lMax + 1), 1)
'Convert value to negative, if not already negative
If Worksheets("Ledger").Cells((lMax + 1), 3).Value > 0 Then Worksheets("Ledger").Cells((lMax + 1), 3).Value = Worksheets("Ledger").Cells((lMax + 1), 3).Value * -1