worksheet_selectionchange(VBA) - not working properly?

DADAZHU

New Member
Joined
Aug 9, 2011
Messages
37
Hi,

I ofter use a combobox in worksheets when a particular cell is clicked, then the combobox will appear over the cell with a number of options for users to choose, once a value on the list is selected the combobox will disappear. the cell's value is left with the selected value.

It works fine for me. However, me problem is the 2nd click following the 1st click, say, I click the same cell after the 1st click, I expect that the combobox will appear again, however, nothing happen, I have to click somewhere else first, and come back to click the cell, the combobox then appears.

Does anyone know how to overcome it?

Many thanks in advance.

David
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
If you click the same cell twice, the selection doesn't change, right?
 
Upvote 0
Thanks for your response.

The problem is that the event was fired at the 1st click, but nothing happens on the 2nd click (when the same cell is still selected).

I tried to select another cell before the 1st event is completed, so the 2nd click on the same cell will work, but the result was not good.
 
Upvote 0
There is no event fired when you select the same cell twice.

You could instead double-click, and use the doubleclick event.
 
Upvote 0
Thanks, shg.

Did you mean use 'Worksheet_BeforeDoubleClick'? it is the only event I can find with worksheet. Even though I still have the same problem. Once the 1st event fired, the 2nd click or doubleclick doesnt work with the cell is selected, unless it is forced to have another cell selected before the 1st event completed, then the user can be fire another event with the cell.

The combobox is not with a form, it is within a worksheet, it's only visible when a user click a fixed cell.
 
Upvote 0
If your options are configured to enable in-cell editing, thjen you need to cancel so that the double-click doesn't leave you in edit mode, requiring you to exit the cell.

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    
    ' do your stuff ...
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

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