Macro use of Select (Replace) variant to extend a range


Posted by Dean Chapman on January 14, 2002 2:06 AM

I am trying run a simple macro to select all unlocked
cells in a sheet. I cannot get get the SELECT(Replace)
variant to work.
A simple coding sample of what I think it should be:
Range("L9,L12,L14,L16").Select
Range("L10,L11,L13,L15").Select Replace:=False
Should select both ranges, but no matter what I try the syntax is thrown out.
Any Ideas before I go mad?
Thanks in anticipation
Dean Chapman

Posted by Ivan F Moala on January 14, 2002 3:14 AM

Dean
This method is ONLY applicable to the Sheets
eg.

Sub test2()
Sheet1.Select
Sheet2.Select False
End Sub

Selects sheets1 + sheets2

To get what you want then use the union eg
Sub test3()
Dim a As Range, b As Range, NewRange As Range
Set a = Range("L9,L12,L14,L16")
Set b = Range("L10,L11,L13,L15")

Set NewRange = Application.Union(a, b)
NewRange.Select
End Sub

HTH


Ivan



Posted by Dean Chapman on January 14, 2002 3:36 AM

Thanks Ivan,
I had misread the help info to mean that it can
be used only when working on sheets (ie. excel)
I see now what it means... as you rightly say only when selecting sheets.
My mind is still in weekend mode!!
Cheers, Dean.