excelbytes
Active Member
- Joined
- Dec 11, 2014
- Messages
- 291
- Office Version
- 365
- Platform
- Windows
What I am trying to do is copy the data and format from O11:O31 into V11:V31 if V11 is empty. But if there is data in V11, or any consecutive column to the right, find the next blank cell in row 11 the paste the data there.
What is happening is when V11 is empty it works. When V11 is not empty it pastes it in W11, which again is correct. But after that, it keeps pasting the values over in W11.
Here is my code:
What is happening is when V11 is empty it works. When V11 is not empty it pastes it in W11, which again is correct. But after that, it keeps pasting the values over in W11.
Here is my code:
VBA Code:
Public Sub NextColumn()
Range("O11:O31").Copy
If IsEmpty(Range("V11")) Then
Range("V11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats
Else
Range("V11").Select
ActiveCell.End(xlToRight).Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats
End If
End Sub