how to display value of a For Loop

Pookiemeister

Active Member
Joined
Nov 26, 2015
Messages
306
Office Version
  1. 365
  2. 2010
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
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,181
Office Version
  1. 365
Platform
  1. Windows
Try
Code:
Debug.Print .List(i)
 

Pookiemeister

Active Member
Joined
Nov 26, 2015
Messages
306
Office Version
  1. 365
  2. 2010
Thank You very much that worked. That makes sense now that I think about it. So simple.
 

Pookiemeister

Active Member
Joined
Nov 26, 2015
Messages
306
Office Version
  1. 365
  2. 2010
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.
 

Pookiemeister

Active Member
Joined
Nov 26, 2015
Messages
306
Office Version
  1. 365
  2. 2010
Just figured out how to do the last question.
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,181
Office Version
  1. 365
Platform
  1. Windows
Glad you sorted it & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,108,788
Messages
5,524,879
Members
409,609
Latest member
Channingz

This Week's Hot Topics

Top