start macro after one click on a cell

littlepete

Well-known Member
Joined
Mar 26, 2015
Messages
503
Office Version
  1. 365
Platform
  1. Windows
hello

i read about 25 website to find how to sort my list on column 7 (column G) with my macro that sorts that way...
not one of the solutions does anything...

i think it is enough to put these lines into microsoft excel / thisworkbook and there into worksheet_selectionchange :

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("g1")) Is Nothing Then Call sorteerlanden
End Sub

so what am i doing wrong ???

again... thanks if i get help ...

pete,
belgium
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Looks fine to me, how isn't working?

Where did you put the code?

It should be in the module of the worksheet that you want to monitor.
 
Upvote 0
hello ;)

on the code pages,
at the left side:

vbaproject
- microsoft excel objects
- page 1
- page 2
- thisworkbook <=============== on this page i put it.

at the top: WORKBOOK.

at the right sight: worksheet_selectionchange

it should work... but i click and nothing happens, i double click and i enter the cel, nothing else ...

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("g1")) Is Nothing Then Call sorteerlanden
End Sub

all it does is start a macro to sort my list on the names of countries (= landen) ...

...

Pete
 
Upvote 0
Right click the sheet tab, click view code,from the dropdowns select worksheet and change.
Paste the code you have except the first line and the End Sub between the two lines that appear.
Remove the code from ThisWorkbook.
 
Upvote 0
hello :)


so the code was in the wrong place :) i noticed the difference :) !
i then put the code on different cells because first i put the sort by country on the label of the column countries
and that didnt work well...

thx for the help :) !!!

Pete
belgium
 
Upvote 0

Forum statistics

Threads
1,214,276
Messages
6,118,630
Members
448,844
Latest member
Jayee04e

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