Printing in a list box

  • Thread starter Thread starter Sheeny
  • Start date Start date
S

Sheeny

Hi is there a way to print something in a list box based on ht
formatting of data in a column?

I want Excel to search through a column and if text in a cell is bol
then to print that text in a list box. Any ideas?

Thanks so much
 
Sheeny,

This is for a userform it works here.

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim i As Long
Dim myrng As Range
Worksheets("Sheet1").Activate
Set myrng = Worksheets("sheet1").Cells(1, 1).CurrentRegion
For i = 1 To myrng.Rows.Count
With UserForm1
If myrng(i, 1).Font.Bold = True Then
.ListBox1.AddItem myrng(i, 1).Value
End If

End With
Next i
End Sub


HTH


Charle
 
This is what I have right now...any ideas as to what i need to do t
make it work??

Private Sub CmdRec_Click()
Application.ScreenUpdating = False
Dim i As Long

Sheet3.Activate

With Sheet3

For i = 1 To .Range("A" & Rows.Count).End(xlUp).Row
If .Cells(i, "A").Font.Bold = True Then
ListOld.AddItem .Cells(i, "A").Value
End If
Next i

End With

End Su
 
Your code works here if the cell's font is really bold.

It doesn't work if the bold is caused by conditional formatting. Is that
what you're looking for by any chance?
 
Hi

Yes I was just playing around and realized thats my problem.

Is there a way to read conditional formatting?

Thanks
 
I usually find the easiest way is to use the same rules in code that
were used in conditional formatting, rather than to try to read the
results of the CF.
 
Im having difficulties with this.

My CF is that if a company is in one list, but not the other, then th
font is bold. (ListOld and ListNew).

The bold font determines if a company is old, ie. not in the new lis
or if a company is new, ie. not in the old list.

Thanks
 
Heres my problem - this code prints the right companies, but it print
in numerous times (everytime I go through the loop) and it also print
the spaces.

Any ideas ?
---------------------------------------------

Private Sub CmdRec_Click()

Dim i As Long

ListOld.Clear

Sheet3.Activate
Sheet3.Range("A4").Select

With Sheet3
' only reads bold, not cond formatting

For i = 1 To .Range("B" & Rows.Count).End(xlUp).Row
For j = 1 To .Range("A" & Rows.Count).End(xlUp).Row
If Sheet3.Cells(i, "B").Value <> Sheet3.Cells(i
"A").Value Then
ListOld.AddItem (Sheet3.Cells(i, "A").Value)
End If
Next j
Next i

End With

End Sub
 

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