Hello...Please correct the code, I have a datasheet whose number of columns is not fixed, it could be 3, 5, or maybe 10, I want to select the last column always - 2 columns back so that I can execute the following code
VBA Code:
Sub Copy_n_Paste()
Dim wsDest As Worksheet: Set wsDest = sheet3
Dim lr As Long, Lastcol As Long
Dim SrchRng As Range, cel As Range
lr = wsDest.Cells(Rows.Count, "a").End(xlUp).Row - 1
Lastcol = wsDest.Cells(5, wsDest.Columns.Count).End(xlToLeft).Column
Set SrchRng = wsDest.Cells(5, Lastcol - 2 & lr)
For Each cel In SrchRng
If cel.Value <> "" Then
cel.Offset(1, 1).Value = cel.Value
cel.Offset(1, 1).NumberFormat = "###0.00"
End If
Next cel
End Sub