how to display value of a For Loop

Pookiemeister

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

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Fluff

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

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
534
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Thank You very much that worked. That makes sense now that I think about it. So simple.
 

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
534
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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

Well-known Member
Joined
Jan 6, 2012
Messages
534
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Just figured out how to do the last question.
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
74,658
Office Version
  1. 365
Platform
  1. Windows
Glad you sorted it & thanks for the feedback
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,826
Messages
5,855,873
Members
431,771
Latest member
CoryMelth

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
Top