Hi!
Can U please explain me the effect of this
Range("M3").Select is understood.....Range("A:M,M3").Select
Columns("A:M").Select is also understood...
but what is
-07-Range("A:M,M3").Select
Hi!
Can U please explain me the effect of this
Range("M3").Select is understood.....Range("A:M,M3").Select
Columns("A:M").Select is also understood...
but what is
-07-Range("A:M,M3").Select
It should make no difference to Range("A:M") select, as this one already selects the whole columns A to M where M3 is a part of.
If it was Range("A:L,M3") it would mean columns A to L plus cell M3. Maybe this is a result of removing some cells.
Could you post some more context on that one?
What I observed is....
Range("B:M").Select...... Columns b to m are selected
Range("B:M,M3").Select...... columns b to m are selected and cell B1 is set selected/active
same when U say
Range("D:K,K3").Select...... columns d to k are selected and cell D1 is set selected/active
regards
The second Range was not Activated, it was Unioned. Basically, record a macro selecting at least 2 entire columns, then hold the Ctrl key and select a cell within the same selection. Now look at your macro. It would look the same, much like this ...
Steiner is correct in that you don't need it. You don't even need to select any of it to work with it - not in VBA. The latter range is selected because it is the last cell unioned in the range because you used a select, and only because of this, otherwise you wouldn't see it selected (not if you were only working with the range).Option Explicit Sub Macro1() 'Macro1 Macro ' Macro recorded 4/6/2005 by Zack Range("B:D,B2").Select Range("B2").Activate End Sub
I have a feeling this is the result of a recorded macro that you are trying to understand. (I could very well be wrong.) Understanding recorded code is a great step and is an excellent learning tool. Don't forget it's equally as important to learn from good code as well. If you post your code, I'd be willing to bet that a much more efficient and cleaner looking code would result. This would be optimal for learning VBA.
My
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables