View Full Version : Solved: Syntax question: Range(....)
YellowLabPro
09-18-2007, 09:47 AM
In the first two lines of code, this is confusing me why the first one is accepted/valid by the compiler rather than the second one.
The third "&" is required to create the proper range stmt. for the compiler, why?
Range("J" & i & ":O" & i).Delete shift:=xlShiftUp
Range("J" & i ":O" & i).Delete shift:=xlShiftUp
For i = lrwSource To 3 Step -1
If Cells(i, "O").Value = "x" Then
Range("J" & i & ":O" & i).Delete shift:=xlShiftUp
End If
Next i
Norie
09-18-2007, 09:53 AM
Doug
It just is.:)
Why do you think it wouldn't be needed?
You are concatenating "J" and(&) i and(&) ":O" and(&) i.
Bob Phillips
09-18-2007, 10:07 AM
When concatenating, every item has to be acted upon, they don't do it implicitly.
YellowLabPro
09-18-2007, 10:17 AM
Thanks Bob.
Norie to answer your ?
When reading it literally- it would be:
Range("J3 & : O3").cells.delete
which if this were even possible is saying these two cells,
not the range of
Range("J3:O3").cells.delete
Bob Phillips
09-18-2007, 10:36 AM
Range("J3,O3").cells.delete
Norie
09-18-2007, 10:42 AM
Thanks Bob.
Norie to answer your ?
When reading it literally- it would be:
Range("J3 & : O3").cells.delete
Eh, no it wouldn't.:dunno
For just two cells it would be this.
Range("J3, O3").Delete
PS You don't need Cells here.:)
YellowLabPro
09-18-2007, 10:47 AM
Bob,
Had not thought about it like that, that is cool. What I was trying to convey was the idea of being literal, the " & : " would not be written / read that way.
But I get what you meant in the first post regarding concatenating and I see your point here of a range being separated by the comma providing two valid ranges....
Thanks.... keeping me on my toes
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.