If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Put a Drop box in the Right Place

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-07, 02:51
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,143
Put a Drop box in the Right Place

I have the Code

Code:
Sub BuildDropDowns(cell)
        Dim Drops As Dropdown
        App_Sheet.Range(cell).Select
        Set Drops = App_Sheet.DropDowns.Add(540, 247.5, 103.5, 15.75)
        Drops.ListFillRange = "$S$2:$S$9"
        Drops.LinkedCell = cell
        Drops.DropDownLines = 8
        Drops.Display3DShading = False
        Set Drops = Nothing
End Sub
I Would like to do is move the DropDown so it sits on of the selected cell each time I pass a cell ref

eg
call BuildDropDowns("D17")
call BuildDropDowns("D19")
call BuildDropDowns("D21")
call BuildDropDowns("D23")

can someone point to the right place

I now .Add(540, 247.5, 103.5, 15.75) = left,top,width,Height

left,width,Height won't move
Top the has be stump.
Where is top ?? and how far is D17 form the top
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
  #2 (permalink)  
Old 12-04-07, 03:26
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,143
Have fix it

though idd show you guys and guyess

by
Code:
Sub BuildDropDowns(cell)
        App_Sheet.Range(cell).Select
        Dim Rang As Range
        Set Rang = App_Sheet.Range(cell)
        Dim Drops As Dropdown
        Set Drops = App_Sheet.DropDowns.Add(540, Rang.Top, 103.5, 15.75)
        Drops.ListFillRange = "$S$2:$S$9"
        Drops.LinkedCell = cell
        Drops.DropDownLines = 8
        Drops.Display3DShading = False
        Set Drops = Nothing
        Set Rang = Nothing
End Sub
remember reading some where about getting the height of a range
well bugger me it works
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
  #3 (permalink)  
Old 12-04-07, 05:12
DavidCoutts DavidCoutts is offline
Registered User
 
Join Date: Jan 2004
Location: Aberdeen, Scotland
Posts: 1,067
okay i know youve solved this but i had a play about as well as i have never actually used drop downs.
Here is my attempt

Code:
Sub testDropdowns()
    Dim rngAdd As Range
    Dim rngList As Range
    Dim wksadd As Worksheet
    
    Set rngAdd = Cells(2, 4) ' Range("D1")
    Set rngList = Range(Cells(1, 1), Cells(8, 1))
    Set wksadd = Worksheets("Sheet1")
    
    Call subAddDropDown(wksadd, rngAdd, rngList)

    Set rngAdd = Nothing
    Set rngList = Nothing
End Sub

Sub subAddDropDown(wksadd As Worksheet, rngAdd As Range, rngList As Range)
    Dim dp As DropDown
    'add a dropdown to the cell rngAdd
    Set dp = wksadd.DropDowns.Add(rngAdd.Left, rngAdd.Top, _
                                        rngAdd.Width, rngAdd.Height)
    'set the dropdown properties
    With dp
        .ListFillRange = rngList.Address
        .LinkedCell = rngAdd
        .DropDownLines = rngList.Rows.Count
    End With
        
    Set dp = Nothing
End Sub
the only real difference is that i am calling the function with a worksheet and range variables. I am using this range variable to determine the cell dimensions. Take from this what you like.

All the best
David
Reply With Quote
  #4 (permalink)  
Old 12-04-07, 13:35
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,143
Dave I like it Thanks for Your input
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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