Return to combobox after running marco

KlausW

Board Regular
Joined
Sep 9, 2020
Messages
236
Office Version
  1. 2016
Platform
  1. Windows
Hi, anyone who can help. I use a combobox to search and find items. I transfer them with a VBA code, when I run it the combobox is emptied as it should be. Now I would like the cursor to be in the combobox after the VBA code has been run. Some who can help.

Sincerely Klaus W

VBA Code:
Sub GoToCell() Worksheets("Prisliste").Range("R4").Select Than Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

igold

Well-known Member
Joined
Jul 8, 2014
Messages
3,222
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
You did not say where the Combobox was located. For ComboBox1:
VBA Code:
'For a Form try
Me.ComboBox1.SetFocus

'For a Worksheet try
ActiveSheet.ComboBox1.Activate
 
Upvote 0

KlausW

Board Regular
Joined
Sep 9, 2020
Messages
236
Office Version
  1. 2016
Platform
  1. Windows
Hi igold
The combobox is located in the sheet Prisliste.
Is that, what you mean?
 

Attachments

  • Combobox.jpg
    Combobox.jpg
    79.4 KB · Views: 3
Upvote 0

igold

Well-known Member
Joined
Jul 8, 2014
Messages
3,222
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Yes. Try the second line of the posted code.

VBA Code:
Worksheets("Prisliste").ComboBox1.Activate
 
Upvote 0
Solution

KlausW

Board Regular
Joined
Sep 9, 2020
Messages
236
Office Version
  1. 2016
Platform
  1. Windows
I am sorry but it still not return to the Combobox.
VBA Code:
Sub GoToCell()

'For a Form try
Me.ComboBox1.SetFocus

'For a Worksheet try

Worksheets("Prisliste").ComboBox1.Activate

End Sub
 
Upvote 0

igold

Well-known Member
Joined
Jul 8, 2014
Messages
3,222
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
It worked on my test sheet with a ComboBox named ComboBox1. What is the name of your Combobox?
 
Upvote 0

KlausW

Board Regular
Joined
Sep 9, 2020
Messages
236
Office Version
  1. 2016
Platform
  1. Windows
It worked on my test sheet with a ComboBox named ComboBox1. What is the name of your Combobox?
ComboBox1
 
Upvote 0

igold

Well-known Member
Joined
Jul 8, 2014
Messages
3,222
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
You're welcome. Thanks for the feedback.
 
Upvote 0

KlausW

Board Regular
Joined
Sep 9, 2020
Messages
236
Office Version
  1. 2016
Platform
  1. Windows
I I just have to remove this line
Me.ComboBox1.SetFocus
Thanks
 
Upvote 0

Forum statistics

Threads
1,186,449
Messages
5,957,905
Members
438,330
Latest member
OCCY1221

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