start macro after one click on a cell

littlepete

Board Regular
Joined
Mar 26, 2015
Messages
224
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
 

Some videos you may like

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).

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
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.
 

littlepete

Board Regular
Joined
Mar 26, 2015
Messages
224
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
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,828
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
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.
 

littlepete

Board Regular
Joined
Mar 26, 2015
Messages
224
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,514
Messages
5,596,611
Members
414,080
Latest member
penguin23

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