ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing in a list box (https://www.excelbanter.com/excel-programming/297334-printing-list-box.html)

Sheeny[_3_]

Printing in a list box
 
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

--
Message posted from http://www.ExcelForum.com


Sheeny[_6_]

Printing in a list box
 
Anyone

--
Message posted from http://www.ExcelForum.com


Charles

Printing in a list box
 
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

--
Message posted from http://www.ExcelForum.com


Sheeny[_7_]

Printing in a list box
 
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

--
Message posted from http://www.ExcelForum.com


Steve Garman

Printing in a list box
 
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?


Sheeny < wrote:

This is what I have right now...any ideas as to what i need to do to
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 Sub


---
Message posted from http://www.ExcelForum.com/



Sheeny[_8_]

Printing in a list box
 
Hi

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

Is there a way to read conditional formatting?

Thanks

--
Message posted from http://www.ExcelForum.com


Steve Garman

Printing in a list box
 
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.

Sheeny < wrote:

Hi

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

Is there a way to read conditional formatting?

Thanks.


---
Message posted from http://www.ExcelForum.com/



Sheeny[_9_]

Printing in a list box
 
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

--
Message posted from http://www.ExcelForum.com


Sheeny[_10_]

Printing in a list box
 
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

------------------------------------------------------

Thanks a lot

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com