Selecting multiple cells in column until specific value

cgorry

New Member
Joined
Sep 7, 2006
Messages
2
Hi all,
I'm trying to create a simple macro that will select multiple cells that are adjacent in a column.

This will be used on several worksheets, and some contain a number of blanks that I want to include.

The list will always begin in say A1, but each will be of differing lengths. I imagined having an "END" or similar value at the very bottom of each list and perform multiple ctrl+shift+down until End is reached, the loop will stop and a copy paste will be carried out and the macro will end.

I realise that this is straightforward but am quite a novice!
Thanks,
Chris
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Do you mean something like this?

Range(Range("A1"), Range("A1").End(xlDown)).Select

This code will start in cell A1 and go down column A until it finds the first blank, then select that whole range.
 
Upvote 0
Hi there,
Close but not quite!

The list will always start in cell A1, and need to select cells starting there going down the column (including blank cells) until a specific value is found (such as END etc).

Thanks again
 
Upvote 0
Try something like this:
Code:
Sub MyHighlightRange()
    
    Dim myValue As String
    
'   Enter value to look for
    myValue = "end"
    
'   Find value in column A
    Columns("A").Find(What:=myValue, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False).Activate
    
'   Highlight range
    Range(Range("A1"), ActiveCell).Select
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top