MarcianoPL
New Member
- Joined
- Sep 23, 2020
- Messages
- 6
- Office Version
- 2016
- Platform
- Windows
Good afternoon everyone!
I was hoping that you could help me solving error with my code.
What I want to achieve is when user type "ok" in any cell the code will copy range directly above target cell and paste it in target cell. And this part is working just fine, it copy-paste as desired, however after paste immediately run-time error 13 pops out. What's even more wierd for me is that after clicking "end" i will get this error for second time if i do anything with pasted range. Debug function highlights IF statement.
Can't make heads or tails out of it...
I was hoping that you could help me solving error with my code.
What I want to achieve is when user type "ok" in any cell the code will copy range directly above target cell and paste it in target cell. And this part is working just fine, it copy-paste as desired, however after paste immediately run-time error 13 pops out. What's even more wierd for me is that after clicking "end" i will get this error for second time if i do anything with pasted range. Debug function highlights IF statement.
Can't make heads or tails out of it...
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = "ok" Then
StartCell = Target.Offset(-7, 0).Address
EndCell = Target.Offset(-1, 0).Address
Range(StartCell, EndCell).Copy Target
Else
End If
End Sub