Rubber Beaked Woodpecker
Board Regular
- Joined
- Aug 30, 2015
- Messages
- 203
- Office Version
- 2021
The following code works very well. However if I change If IsEmpty(destination.Range("X5")) Then to If IsEmpty(destination.Range("AA5")) Then the macro pastes in column A1.
What am I doing wrong please as I would like the macro to paste in column AA the first time it is run.
TIA
What am I doing wrong please as I would like the macro to paste in column AA the first time it is run.
TIA
VBA Code:
Sub logBalance()
Dim source As Worksheet
Dim destination As Worksheet
Dim emptyColumn As Long
Set source = Sheets("Sheet1")
Set destination = Sheets("Sheet1")
source.Range("o5:o16").Copy
emptyColumn = destination.Cells(5, destination.Columns.Count).End(xlToLeft).Column
If IsEmpty(destination.Range("X5")) Then
destination.Cells(1, 1).PasteSpecial Transpose:=True
Range("S1").Select
Application.CutCopyMode = False
Else
emptyColumn = emptyColumn + 1
destination.Cells(5, emptyColumn).PasteSpecial Transpose:=False
Application.CutCopyMode = False
End If
End Sub