Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Control on worksheet

If you use controls from the Forms toolbar, you can assign the same procedure to
multiple controls.

Option Explicit
Sub control_on_worksheet()
Dim myPick As Long
dim myDD as DropDown
set myDD = activesheet.dropdowns(application.caller)

with mydd
mypick = .listindex
'activecell.value = .list(mypick)
'or to avoid an extra variable
activecell.value = .list(.listindex)
.value = 0
end with
end sub

Remember that this code goes in a General module--not behind the worksheet.

And I didn't know what the variable w did--I changed the .value to 0.


Arran wrote:

I'm new to VBA, so excuse the basic nature of this question. Thought I had
read some where you could assign the some macro to more than one control. I
have experimented with changing the code below without any success. Is it
possible, if so what corrections are required?

Many thanks
Arran

Sub control_on_worksheet()
Dim mypick As Variant
With Worksheets("April 05 - April 06").DropDowns("Drop Down 13, Drop
Down 14")
' set the value of mypick to the index number
' of the item chosen in the drop-down.
mypick = .ListIndex
'extract the actual item and put it into
'the active cell on the worksheet.
ActiveCell.Value = .List(mypick)
'empty out the drop-down.
.Value = w
End With
End Sub


--

Dave Peterson
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
How to control y scaling from worksheet Marko Pinteric Excel Discussion (Misc queries) 3 April 10th 06 12:54 PM
remove a control from a worksheet joe Excel Programming 1 February 21st 06 07:38 PM
Reference to ActiveX control on worksheet requires full worksheet name Ian Ripsher[_5_] Excel Programming 3 June 25th 05 04:22 PM
Control for Worksheet static coal_miner Excel Worksheet Functions 1 June 7th 05 06:38 PM
A control that does not scroll with worksheet John[_35_] Excel Programming 3 February 28th 04 04:18 PM


All times are GMT +1. The time now is 07:26 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"