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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
57,023
Office Version
  1. 365
Platform
  1. Windows
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.
 

cgorry

New Member
Joined
Sep 7, 2006
Messages
2
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
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
57,023
Office Version
  1. 365
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,130,167
Messages
5,640,536
Members
417,151
Latest member
ChickenTenderer

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
Top