how to display value of a For Loop

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Code:
Private Sub cmbSDPFLine_Change()    
    Dim i As Integer
    
    Select Case cmbSDPFLine
        Case Is = "SDPF - Line 1 "
            With Me.ListBox1
                .Clear
                .List = Sheets("1st Shift").Range("C7", Sheets("1st Shift").Range("C29").End(xlUp)).Value
                For i = 0 To Me.ListBox1.ListCount - 1
                    Debug.Print i
                Next i
            End With
    End Select


End Sub
I have list box of people's names. When I step through the program and get to the For Loop it displays 0-8 in the immediate window. Which makes sense because I have nine names listed. Is there a way to display the names with debug.print instead of numbers. I've already tried Debug.Print i.value but I get a "Compile error: Invalid qualifier".

Thank You
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try
Code:
Debug.Print .List(i)
 
Upvote 0
Thank You very much that worked. That makes sense now that I think about it. So simple.
 
Upvote 0
The debug.print was for test purposes. So now once I can read a name, how can I remove the debug print and loop through a list of names to find that person's name? Because when I remove the Debug.Print I get a "Compile Error: Invalid use of property"
Thank you.
 
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top