• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Who can Help? What's wrong with this

SniperHex

New Member
I tried to run this code to fill column headers in a comboBox, but it gives me an error!!.

Code:
Dim Cell As Range 
For Each Cell In Sheet1.Range(Cells(1, 1), Cells(1, 8))     S
heet2.ComboBox1.AddItem (Cell.Value)     
Next Cell

Note: data is in sheet1
ComboBox1 is in sheet2
the code excutes when workbook opens.

when I use this code it works:
Code:
Dim Cell As Range 
For Each Cell In Sheet1.Range("A1", "H1")     
Sheet2.ComboBox1.AddItem (Cell.Value)     
Next Cell

For a reason, I want to use
Sheet1.Range(Cells(1, 1), Cells(1, 8))
instead of
Sheet1.Range("A1", "H1")

Thank you.
 
Back
Top