0

How do I populate a combobox in a userform with the values in an Excel sheet?
Say sheet name as "Reg ALL - current".
I need to populate the value from cell AI (which is a date column).

Also I need to increment the date one day from AJ to cell BF.
Example: if AI holds value (19/06/2019) then AJ should hold (20/06/2019) and so on until BF.

2
  • 1
    What have you tried so far? The ComboBox has an AddItem method and a List property both of which can be used to assign to it. It's not at all clear what the rest of your question is talking about incrementing dates on a worksheet. Please try to improve this question. Commented Jun 19, 2019 at 12:40
  • You can also look into the .RowSource property. Commented Jun 19, 2019 at 12:48

2 Answers 2

1

There are different ways. If you have one set range of cells (that's what I assume reading your question) that won't change, you could just set the RowSource property of your combobox.

For example:

enter image description here

enter image description here

Apply to your situation:

  • Cell AI1 holds your date
  • Cell AJ1 holds formula =AI1+1
  • Drag formula to cell BF1 (assuming you always want to add to the value in AI1, the formula will keep doing this for you)
  • Use RowSource property and fill in =Sheet1!AI1:BF1

Conclusion, no VBA needed at all! If I understood your question well enough that is.

Sign up to request clarification or add additional context in comments.

Comments

0

Here is simple solution Just add a button, paste this.

Dim i As Long

'Clear existing items
ComboBox1.Clear

'36 (AJ) column to 58 (BF) column
For i = 36 To 58

    ComboBox1.AddItem ActiveSheet.Cells(1, i).Value

Next i

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.