Results 1 to 6 of 6

Thread: VBA Questions

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    32

    Question

    I have two questions...both of them are in VBA

    1) Is there a way i can embed a combo box directly in the cell. so it the combobox is exactly the same size as the cell it needs to go in.

    2) the other quesiton is, since i can't use control arrays in VBA (at least i don't think so) is there an easy way to reference around 30 combo boxes.

    IF yes, can i get an example.

    thanks!

  2. #2
    Guest
    Dim Ctrl As ComboBox

    For Each Ctrl In Me.Controls
    If TypeOf Ctrl Is ComboBox Then
    'do stuff here
    End If
    Next

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    32
    me.controls doesn't work in VBA.

    At least i keep getting an error

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Hmm... That's strange, under the UserForm class in the object browser there is clearly a controls collection. Umm... that's odd, I take it you are writing this in a userform's code, not in a module? ie. the keyword 'Me' is valid?
    Harry.

    "From one thing, know ten thousand things."

  5. #5
    Guest
    sorry had it wrong, it should be like this:


    Dim ctrl As Control

    For Each ctrl In Me.Controls
    If TypeOf ctrl Is ComboBox Then
    ctrl.(someproperty here)
    End If
    Next
    End Sub

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    32
    I haven't tried your suggestion, but will this work in a worksheet. I don't have a user form. The combo boxes are placed directly on a spreadsheet over a cell.

    Don't know if this makes a difference, but i'll try it.

    any ideas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width