Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Challenge of the day: linking VBA code to combo box selections

I have created a combo box by selecting a cell and using Data<Validation<List
and selecting values on a different worksheet.

I would like for when a user selects a value from the combobox, for a VBA
function to run (to change certain cell properties).

Is this possible???

Thank you very much.
  #2   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Challenge of the day: linking VBA code to combo box selections

Assuming your combobox is in cell G2, in the worksheet code try something like:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$2" Then
Range("G5") = Target.Value 'do something with value
End If
End Sub
--
Les Torchia-Wells


"Todd in Dayton" wrote:

I have created a combo box by selecting a cell and using Data<Validation<List
and selecting values on a different worksheet.

I would like for when a user selects a value from the combobox, for a VBA
function to run (to change certain cell properties).

Is this possible???

Thank you very much.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Challenge of the day: linking VBA code to combo box selections

Right click on the sheet tab of the sheet with the dropdown datavalidation
and select view code. Put in code like this

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler
If Target.Address = "$B$9" Then
Application.EnableEvents = False
Call MyMacro
End If
ErrHandler:
Application.EnableEvents = True
End Sub

As written, this reacts to changes in cell B9. The code you want to run
should be in a subroutine in a general module in the workbook and have the
name mymacro (of course that can be changed as can the cell reference).

Note that this will not work in xl97 and earlier.

--
Regards,
Tom Ogilvy


"Todd in Dayton" wrote:

I have created a combo box by selecting a cell and using Data<Validation<List
and selecting values on a different worksheet.

I would like for when a user selects a value from the combobox, for a VBA
function to run (to change certain cell properties).

Is this possible???

Thank you very much.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box Showing Date Selections TiredAlison Excel Discussion (Misc queries) 4 November 23rd 09 06:47 AM
Counting Combo Drop Down Box Selections Jeff Excel Worksheet Functions 1 April 16th 08 08:38 PM
Can List or Combo Box have multiple selections? [email protected] Excel Worksheet Functions 2 April 6th 06 03:41 PM
A Challenge (Linking word and Excel) Mr M Walker[_2_] Excel Programming 1 July 25th 05 09:33 AM
Multiple Selections in a Combo Box??? hce[_2_] Excel Programming 1 September 3rd 04 04:54 PM


All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"