Values from bold cells to combobox?

  • Thread starter Thread starter Bmj
  • Start date Start date
B

Bmj

Hi,

I have several sheets with cell-values which I want to use in a ComboBox
(AddItem) - not the whole range, but only those cells with eg a bold font.
How can I do this with VBA? There are also some sheets where the wanted
cells are not with a bold fold, but with a "x" as value in the cell next to
it (differnt column). Is there an easy way of also including these values??

Best Regards,
Bmj
 
If Range("A1").Font.Bold Then
Combobox1.AddItem Range(A1").Value
End If

If Range("H1").Offset(0,1).Value = "x" Then
Combobox1.AddItem.Range("H1").Value
End If
 
hmmm... no, it didn't work. The Combox is empty. But, this seems to work
(but only solves the bold font problem):

Dim rwindex As Integer
Dim colIndex As Integer

For rwindex = 1 To 10
For colIndex = 1 To 10
With Worksheets("Shett1").Cells(rwindex, colIndex)
If .Font.Bold = True Then Combobox1.AddItem
Cells(rwindex, colIndex).Value
End With
Next colIndex
Next rwindex

Regards,
Bmj
 
so combine them


Dim rwindex As Integer
Dim colIndex As Integer

For rwindex = 1 To 10
For colIndex = 1 To 10
With Worksheets("Shett1").Cells(rwindex, colIndex)
If .Font.Bold = True Or _
.Offset(0,1).Value = "x" Then
Combobox1.AddItem _
Cells(rwindex, colIndex).Value
End If
End With
Next colIndex
Next rwindex
 
Thank you :-))


Bob Phillips said:
so combine them


Dim rwindex As Integer
Dim colIndex As Integer

For rwindex = 1 To 10
For colIndex = 1 To 10
With Worksheets("Shett1").Cells(rwindex, colIndex)
If .Font.Bold = True Or _
.Offset(0,1).Value = "x" Then
Combobox1.AddItem _
Cells(rwindex, colIndex).Value
End If
End With
Next colIndex
Next rwindex


--

HTH

RP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top