Consulting

Results 1 to 5 of 5

Thread: Solved: .AddItme help

  1. #1

    Solved: .AddItme help

    Can someone give me an idea why this error's out?

    For iLCV = 1 To 10

    ActiveWorkbook.Worksheets("Form").cmbSite.AddItem = Range("B" & iLCV).Text

    Next iLCV

    I am getting runtime error 438 here.

    On a worksheet named Form, i have a combo box named cmbSite. I am trying to loop through (in this case) 10 rows of data to populate that combo box.

    the cell where the box is shows =EMBED("Forms.ComboBox.1","")

    thanks for the help

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,882
    remove the = sign?

    You could do this with one line (I haven't qualified 'Range("B1:B10").Value' so this assumes you've made sure the active sheet is the right sheet - this is no different from your own code in this respect)
    [vba]ActiveWorkbook.Worksheets("Form").cmbsite.List = Range("B1:B10").Value[/vba] and if you wanted the combobox list to update itself automatically when the values in the range change use:
    [vba]ActiveWorkbook.Worksheets("Form").cmbsite.ListFillRange = "B1:B10"[/vba] (this last assumes that the range B1:B10 is on the Forms sheet)
    Last edited by p45cal; 11-07-2009 at 05:23 AM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Remove "="
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Quote Originally Posted by mdmackillop
    Remove "="
    yup yup, figured that out shortly after i posted. came back here three times to remove / delete post but site was down?

    anyway, thanks for the help!

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You could also consider a Dynamic Range Name and the ListFillRange property to fiil the combo.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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