so I have a VBA function that keeps throwing the error ‘Application-defined or object-defined error’ and I can’t figure out why. The function is meant to copy a block of cells from one sheet to another. I’ve used code like this in other areas with no problems, so don’t understand why this isn’t working.
'update on main screen
Public Sub mainImageUpdate(roomstring)
set yoffset = Worksheets("Source").Range("A:A").Find(roomstring, , xlValues, xlWhole).Row
Worksheets("Source").Range("B1:AB10").Offset(yoffset - 1, 0).Copy _
Destination:=Worksheets("Main").Range("O5")
End Sub
Public Sub mainImageUpdate(roomstring)
Dim Y as range
set y = Worksheets("Source").Range("A:A").Find(roomstring, , xlValues, xlWhole) 'look for it
if not y is nothing then 'did you find it?
Worksheets("Source").Range("B10:AB10").Offset(y.row - 1, 0).Copy _
Destination:=Worksheets("Main").Range("O5")
else
'do something?
end if
End Sub