Unselecting

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,099
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
After Selection.Find.. the whole column in question remains selected/highlit.
I don't really want to leave it like that but so far these suggestions don't seem to work in my version 2007

SendKeys"{ESC}"
Application.CutCopyMode = False

Any other things I could try (apart from selecting something else?)

I tried Selection.Clear but I won't be trying it again !! :rofl:
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
If I correctly understand what you mean, the cell range is highlighted.

It's the same as if you selected a range manually.

To "unhighlight" (or more accurately: not have that range selected), select a single cell.

Activesheet.range("A1").select

sheets("Sheet1"). range("A1").select

are alternatives... the first obviously takes the currently active sheet. The second allows you to specify the sheet.

Of course, you can select whatever range you want instead of "A1"
 
Upvote 0
The only way to change the selection is to select something else.
Do you need to select the whole column? Why not change your code so that it does not require selection of the whole column?
 
Upvote 0
Thanks very much for the replies! Actually I don't want to select the whole column.. just the first row where Col "A" = something.
I was hoping to use SQL but the syntax is a bit wonky and I'm waiting on an answer (to another question here) about that.

Perhaps you know a better method than what I'm using ?
Code:
 With Worksheets(cSheet, Col)
        Worksheets(cSheet).Range(Col & ":" & Col).Select
        Set cell = Selection.Find(What:=Dat, After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=Entire, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
    
        If cell Is Nothing Then 'do nothing
            Else
                FirstRowForYear = cell.Row
        End If

        Set cell = Nothing
    End With

Or, if you want the bigger picture, my ultimate goal is to get the Contents of Col "C" (or just the row number) into an Array where a Date Falls within Col 'E' holding Date1 and 'F', holding Date2
(Entire is a variable I set to XLWhole or XlPart depending....)
 
Last edited:
Upvote 0
Your code indicates that Sheet(cSheet) is the active sheet, so all you need is the following (no selection involved) :
Code:
Set cell = Columns(col).Find(What:=Dat, After:=Cells(1, col), LookIn:=xlFormulas, _
    LookAt:=Entire, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)
If Not cell Is Nothing Then FirstRowForYear = cell.Row
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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