VBA De-select

Katy Jordan

Well-known Member
Joined
Jun 28, 2008
Messages
596
Hi, the below retains the selection in worksheet array, how can i get the code to de-select

i tried adding .Range("A5").Select, but the selection is still in place

Code:
 With Worksheets(WSary(a)).Range("A6:M" & NR & ",Q6:R" & NR)
        .Borders.LineStyle = xlNone
        .Borders.LineStyle = xlContinuous
        .Interior.ColorIndex = 0
        .Borders.Weight = xlHairline
       [COLOR=Red] .Range("A5").Select[/COLOR]
       End With
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I'd try the line outside the With Statement, and see if that works..

Outside of that is another with

Code:
With Raw


With Worksheets(WSary(a)).Range("A6:M" & NR & ",Q6:R" & NR)
        .Borders.LineStyle = xlNone
        .Borders.LineStyle = xlContinuous
        .Interior.ColorIndex = 0
        .Borders.Weight = xlHairline
        .Range("A5").Select
       End With
End With
 
Upvote 0
If you want to select cell A5, try just removing the '.' from the front of the red line.

Edit: Or if the sheet in question may not be the ActiveSheet, then try changing the red line to
Code:
.Parent.Range("A5").Select
 
Upvote 0
Your code is not selecting anything. What do you want to de-select?
Hi, the below retains the selection in worksheet array, how can i get the code to de-select

i tried adding .Range("A5").Select, but the selection is still in place

Code:
 With Worksheets(WSary(a)).Range("A6:M" & NR & ",Q6:R" & NR)
        .Borders.LineStyle = xlNone
        .Borders.LineStyle = xlContinuous
        .Interior.ColorIndex = 0
        .Borders.Weight = xlHairline
       [COLOR=Red] .Range("A5").Select[/COLOR]
       End With
 
Upvote 0
If you want to select cell A5, try just removing the '.' from the front of the red line.

Edit: Or if the sheet in question may not be the ActiveSheet, then try changing the red line to
Code:
.Parent.Range("A5").Select

I tried both your methods, the data is still selected
 
Upvote 0
I tried both your methods, the data is still selected
Yes, my mistake. If the sheet in question is not the active sheet, you would have to make it the active sheet before selecting the cell.
Code:
.Parent.Activate
Range("A5").Select
The other question is do you really need to select this cell since you rarely need to select anything to work with it in vba?
 
Upvote 0
Yes, my mistake. If the sheet in question is not the active sheet, you would have to make it the active sheet before selecting the cell.
Code:
.Parent.Activate
Range("A5").Select
The other question is do you really need to select this cell since you rarely need to select anything to work with it in vba?

No i dont need to have that cell selected, i just want the selection de-selected.

Is there a code that will de-select the whole workbook, that might work
 
Upvote 0
I don't know what you mean by that.

Did you try the last code I suggested anyway?

Yeah i tried that code but it didnt work, so i thought if there is a code that will look for each worksheet in Workbook, if cells are selected then de-select them
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,879
Members
452,948
Latest member
Dupuhini

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