View Full Version : can anyone see an isue with this line? object defined error
samuelimtech
07-11-2014, 06:31 AM
Hi all,
this is where im having the issue and im unsure why.
thanks for any help guys!
Sheets("Management").Range(Cells(2, 1), Cells(finalrow, 1)).Select
p45cal
07-11-2014, 06:52 AM
you probably haven't assigned anything to finalrow (make sure the spelling's right).
Paul_Hossler
07-11-2014, 07:32 AM
If there is something valid in finalrow, then you might be not referencing the Management sheet. Some thoughts ...
With Sheets("Management")
.Select
Range(.Cells(2, 1), .Cells(finalrow, 1)).Select
End With
No dot on Range, but dots on .Cells
samuelimtech
07-11-2014, 08:33 AM
Hi thanks for the help but ive suused it, i didnt know the sheet had to be active.
That's the main reason you should refrain form 'select' and 'activate' in VBA
Paul_Hossler
07-12-2014, 05:21 AM
It only has to be active because of the way you were using it
snb is very correct
If for example, you wanted to copy the data to a another sheet
With Sheets("Management")
call Range(.Cells(2, 1), .Cells(finalrow, 1)).Copy (Worksheets ("Summary").Cells(45,1))
End With
That way it doesn't matter (aka "Keeps me out of trouble") which sheet is active, and it doesn't even have to be either of those two
Aflatoon
07-14-2014, 01:15 AM
There should really be a dot in front of Range too. If the code is in the module for a different sheet, you'll get an error otherwise.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.