Excel 2007 records the sort operation differently than Excel 2003 says Dick Kusleika, and he has samples of recorded code to prove it.
For the experts, this just backs up what they've known for ages - pawing through the entrails of a recorded macro can help us understand the machinery in VBA, but a recorded macro isn't necessarily the best solution.
Dick's Blog item is frightening to me - it points out that "In this [2007] version, the range A1:E12 is hard-coded. When a new row is added, the 2003 code works the same and the 2007 code fails."
That sounds as if Recorded macros might be a bigger trap-in-waiting for many a novice macro-recorder than ever it was in 2003 or predecessors.
I'll avoid a rant along the lines of "After all these years how can they drop back into recording absolute addresses ..." and fail again.
(Seconds later) countered/augmented I see by Hans's Response to Stuart's post "I never did understand array formulae"
RECORDING (Sorting) in Excel 2007 vs. Excel 2003
-
- PlutoniumLounger
- Posts: 15656
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
RECORDING (Sorting) in Excel 2007 vs. Excel 2003
He who plants a seed, plants life.
-
- Microsoft MVP
- Posts: 656
- Joined: 24 Jan 2010, 17:51
- Status: Microsoft MVP
- Location: Weert, The Netherlands
Re: RECORDING (Sorting) in Excel 2007 vs. Excel 2003
Recorded macros have never been the best solution to create your macro's. They are a very good learning tool to get to know VBA and to get an impression of teh syntax needed for some actions. In fact, I often record small macros just to get all the arguments of an action, especially sort and find. Sounds like a good idea to leave Excel 2003 on my system so I can record the Sort action so it works on all versions!
-
- PlutoniumLounger
- Posts: 15656
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: RECORDING (Sorting) in Excel 2007 vs. Excel 2003
Jan, I quite agree. It looks as if a higher proportion of novices (who think that recording a macro is "Recording in VBA") are going to fall into this absolute-address trap, 'though.Jan Karel Pieterse wrote:Recorded macros have never been the best solution to create your macros.
He who plants a seed, plants life.