LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Filling a listbox depending on font index

I have a worksheet with a range called 'Ledger'

What I want to do is fill a LISTBOX with the values UNLESS the first
cell is font color red (colorindex 3).

I then need to use this listbox to select items and on exiting colour
cell A+n red if I check them.

The problem I have to overcome is that by doing an If/Then to check if
the first cell is Red the range count goes awry :(

Here is my code:

Private Sub UserForm_Initialize()
Dim i As Single
Dim nRows As Integer
Dim Fmt As String 'format string

Fmt = "##0.00"

' Count rows in range 'Ledger'
nRows = Range("Ledger").Rows.Count ' Ledger is a range

With Me.ListBox1
.Clear ' remove existing content
.ColumnCount = 8
.ColumnWidths = "0,130,0,100,70,70,0,0"

For i = 1 To nRows

' Add 4 to range as this is where it starts (5th row down)

' Add item to the list IF it's colorindex is NOT red (colorindex 3)
If Range("A" & i + 4).Font.ColorIndex < 3 Then

.AddItem ' add a new row
.List(i - 1, 0) = Range("A" & i + 4).Value
.List(i - 1, 1) = Range("B" & i + 4).Value
.List(i - 1, 2) = Range("C" & i + 4).Value
.List(i - 1, 3) = Range("D" & i + 4).Text
.List(i - 1, 4) = Range("E" & i + 4).Value
.List(i - 1, 5) = Range("F" & i + 4).Value
.List(i - 1, 6) = Range("G" & i + 4).Value
.List(i - 1, 7) = Range("H" & i + 4).Value

End If

End With

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing font colour depending on cell value RunRonnyRun Excel Worksheet Functions 1 October 27th 08 08:28 PM
ListBox Drop Down Font Size Phil B. Excel Worksheet Functions 2 September 19th 08 02:43 PM
How to use INDEX in an ARRAY that changes depending on a criteria Daniel @ Logicim Excel Worksheet Functions 3 December 18th 07 05:30 PM
Problem using INDEX to select items in listbox Shazbot Excel Discussion (Misc queries) 3 April 28th 06 09:06 AM
Filling cells depending on two conditions dziw Excel Worksheet Functions 1 September 22nd 05 04:29 PM


All times are GMT +1. The time now is 04:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"