Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to select non continuos cells?

Status
Not open for further replies.

Molfetta

Technical User
Apr 16, 2007
3
IT
Hi everybody,
I'm an Italian VBA user and I'd like to select a flexibile numer of non continuos cells with a macro. What can vary is not only the number of the cells but also their position in the column. To explain: the code - range("A1,A5,A10").select make the selection of the single cells at the same time. How can I make it flexible, varying the number of the cells and the row of each?
Thanks a lot
 
You may consider the Application.Union method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Code:
For x = StartCell To EndCell
    If Range("A" & x) = Criteria Then
        If Len(strRange) = 0 Then
                strRange = "A" & x
            Else
                strRange = strRange & ",A" & x
        End If
    End If
Next
Range(strRange).Select
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top