-
Jun 5th, 2011, 03:40 PM
#1
Thread Starter
Member
VBA - ActiveCell.Select
I'm looking at code written by someone else and trying to make it cleaner/faster/nicer. I'm no expert so it's a good learning experience. One thing I see a few times is
Isn't the ActiveCell already selected? So, isn't this command a waste of time? And another time I saw something even worse.
Code:
ActiveCell.Offset(0,0).Range("A1").Select
Isn't this an even more complicated way of saying the same thing, also accomplishing nothing?
-
Jun 5th, 2011, 04:06 PM
#2
Re: VBA - ActiveCell.Select
there is some really cruddy code posted on the internet
also some really good, i think the above is an example of the bad
where ever possible you should avoid selecting cells at all, work with fully qualified ranges
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 5th, 2011, 07:59 PM
#3
Thread Starter
Member
Re: VBA - ActiveCell.Select
My guess is this code came from recording a macro, but I'm not sure. I know that in the process of recording macros, a lot of Select statements appear that are unnecessary.
-
Jun 6th, 2011, 03:25 AM
#4
Re: VBA - ActiveCell.Select
My guess is this code came from recording a macro
i think you are probably correct
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|