I have this VBA code to copy and paste from cell K10 to C13-22 and it works okay but when it gets to 22 it comes up with a runtime error 91 - object variable or With Block variable not set. I assume this is because it does not know what to do when it gets to 22. I wondered if you knew a way of displaying a message to say something like ran out of space when it reaches the end instead of the default Excel message asking to debug OR alternatively just stop?
Here is the code I used:
Sub CopyBelow()
'
' macro to copy below
'
'
Range("K10").Select
Selection.Copy
Range("C12:C22").Find("").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Here is the code I used:
Sub CopyBelow()
'
' macro to copy below
'
'
Range("K10").Select
Selection.Copy
Range("C12:C22").Find("").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub