how to display value of a For Loop

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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
Just figured out how to do the last question.
 
Last edited:
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,567
Messages
6,120,268
Members
448,953
Latest member
Dutchie_1

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