Srinivas_New
New Member
- Joined
- Jun 16, 2021
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hello All,
I'm new to VBA. I'm trying to do crew scheduling. So one employee will do 28 days work and 28 days off and goes on for 10 employees.
Question- 1
This code works only from D4 and goes on. This is good but I need is the code to work on any empty cell I click. Say I select on G4 or H4 etc , it should start the copying from there.
Sub CopyToColumn2()
Dim lLastCol As Long
lLastCol = WorksheetFunction.Max(4, Cells(1, Columns.Count).End(xlToLeft).Offset(, 1).Column)
Cells(1, lLastCol).Resize(1, 10).Value = Application.Transpose(Array(Range("B5")))
End Sub
I'm new to VBA. I'm trying to do crew scheduling. So one employee will do 28 days work and 28 days off and goes on for 10 employees.
Question- 1
This code works only from D4 and goes on. This is good but I need is the code to work on any empty cell I click. Say I select on G4 or H4 etc , it should start the copying from there.
Sub CopyToColumn2()
Dim lLastCol As Long
lLastCol = WorksheetFunction.Max(4, Cells(1, Columns.Count).End(xlToLeft).Offset(, 1).Column)
Cells(1, lLastCol).Resize(1, 10).Value = Application.Transpose(Array(Range("B5")))
End Sub