Consulting

Results 1 to 3 of 3

Thread: Sleeper: Combo Box Range problem

  1. #1
    VBAX Newbie
    Joined
    Nov 2004
    Posts
    1
    Location

    Sleeper: Combo Box Range problem

    Hi, I have created a range in Excel which selects all of the blank cells in column 5 of another range. I now want to use an offset of (0,-4) in this range as the rowsource in a combo box. Unfortunatly I'm not having much success at the moment:

    Dim bob As Range
        Dim a As Range
    Set a = Range("a1").CurrentRegion
        Set bob = a.Columns(5).SpecialCells(xlCellTypeBlanks).Offset(0, -4)
        bob.Select
        cboPatientName.RowSource = bob.Address
    bob is certainly the range that I want but no luck in getting it to appear in the combo box. Any help would be appreciated even if to say it is not possible this way

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    It looks like the multiple sections in the range were messing up the row source. Try this:

    Dim bob As Range
    Dim a As Range
    Dim cel As Range
    Set a = Range("a1").CurrentRegion
    Set bob = a.Columns(5).SpecialCells(xlCellTypeBlanks).Offset(0, -4)
    For Each cel In bob
        Me.ComboBox1.AddItem (cel.Text)
    Next

  3. #3
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    I also editted your post to use VBA tags. Notice how the code looks like actual code now. To use the tags write this when you post:


    Code Here

    When you really do this replace the parentheses with brackets [].

Posting Permissions

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