ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Confused about the ListBoxes. (https://www.excelbanter.com/excel-programming/410201-confused-about-listboxes.html)

fishonspeed[_2_]

Confused about the ListBoxes.
 
I have two list boxes that should both show the exact same thing. So I used
the exact same code for both boxes just with different variables that have
the exact same values.

The problem is that only the first list box shows anything. And even if I
take the code for ListBox1 out and leave everything for ListBox2 in the
selections still show up in ListBox1. If I have the code for both boxes
written, the selections still only show in ListBox1 and ListBox2 is blank.

Any ideas as to why this may be happening?
--
I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed

Per Jessen

Confused about the ListBoxes.
 
Hi

Showing the code used to populate the list boxes will enable us to see what
is happening.

Regards,
Per

"fishonspeed" skrev i meddelelsen
...
I have two list boxes that should both show the exact same thing. So I used
the exact same code for both boxes just with different variables that have
the exact same values.

The problem is that only the first list box shows anything. And even if I
take the code for ListBox1 out and leave everything for ListBox2 in the
selections still show up in ListBox1. If I have the code for both boxes
written, the selections still only show in ListBox1 and ListBox2 is blank.

Any ideas as to why this may be happening?
--
I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed



fishonspeed[_2_]

Confused about the ListBoxes.
 
Ah. That is true.
Here it is:

With Me.ListBox1
For ScreenCounter = 1 To .ListCount
If .Selected(ScreenCounter - 1) Then
ScreenTracker = ScreenTracker + 1
mySheetNames(ScreenTracker) = .List(ScreenCounter - 1)
Sheet(ScreenCounter) = mySheetNames(ScreenTracker)
End If
Next ScreenCounter
End With

With Me.ListBox2
For ScreenCounter2 = 1 To .ListCount
If .Selected(ScreenCounter2 - 1) Then
ScreenTracker2 = ScreenTracker2 + 1
mySheetNames2(ScreenTracker2) = .List(ScreenCounter2 - 1)
Sheet2(ScreenCounter2) = mySheetNames2(ScreenTracker2)
MsgBox (ScreenCounter2 & ScreenTracker2)
End If
Next ScreenCounter2
End With



--
I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed


"Per Jessen" wrote:

Hi

Showing the code used to populate the list boxes will enable us to see what
is happening.

Regards,
Per

"fishonspeed" skrev i meddelelsen
...
I have two list boxes that should both show the exact same thing. So I used
the exact same code for both boxes just with different variables that have
the exact same values.

The problem is that only the first list box shows anything. And even if I
take the code for ListBox1 out and leave everything for ListBox2 in the
selections still show up in ListBox1. If I have the code for both boxes
written, the selections still only show in ListBox1 and ListBox2 is blank.

Any ideas as to why this may be happening?
--
I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed




Per Jessen

Confused about the ListBoxes.
 
Hi again

I'm not sure what you are trying to to with this code part. What are the
variables refering to ?

Regards,
Per

"fishonspeed" skrev i meddelelsen
...
Ah. That is true.
Here it is:

With Me.ListBox1
For ScreenCounter = 1 To .ListCount
If .Selected(ScreenCounter - 1) Then
ScreenTracker = ScreenTracker + 1
mySheetNames(ScreenTracker) = .List(ScreenCounter - 1)
Sheet(ScreenCounter) = mySheetNames(ScreenTracker)
End If
Next ScreenCounter
End With

With Me.ListBox2
For ScreenCounter2 = 1 To .ListCount
If .Selected(ScreenCounter2 - 1) Then
ScreenTracker2 = ScreenTracker2 + 1
mySheetNames2(ScreenTracker2) = .List(ScreenCounter2 - 1)
Sheet2(ScreenCounter2) = mySheetNames2(ScreenTracker2)
MsgBox (ScreenCounter2 & ScreenTracker2)
End If
Next ScreenCounter2
End With



--
I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed


"Per Jessen" wrote:

Hi

Showing the code used to populate the list boxes will enable us to see
what
is happening.

Regards,
Per

"fishonspeed" skrev i meddelelsen
...
I have two list boxes that should both show the exact same thing. So I
used
the exact same code for both boxes just with different variables that
have
the exact same values.

The problem is that only the first list box shows anything. And even if
I
take the code for ListBox1 out and leave everything for ListBox2 in the
selections still show up in ListBox1. If I have the code for both boxes
written, the selections still only show in ListBox1 and ListBox2 is
blank.

Any ideas as to why this may be happening?
--
I dispise your poor English and inability to use punctuation correctly
...
or at all.
~FishOnSpeed





fishonspeed[_2_]

Confused about the ListBoxes.
 
Their counting the sheets and placing the sheet names in a list that is then
displayed in a list box. I'm just confused as to why one works while the
other doesn't. The second one doesn't even execute. I've tried placing
MsgBoxes in several places throughout the second procedure and nothing
happens. The program completely skips that chunk of code.

I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed


"Per Jessen" wrote:

Hi again

I'm not sure what you are trying to to with this code part. What are the
variables refering to ?

Regards,
Per

"fishonspeed" skrev i meddelelsen
...
Ah. That is true.
Here it is:

With Me.ListBox1
For ScreenCounter = 1 To .ListCount
If .Selected(ScreenCounter - 1) Then
ScreenTracker = ScreenTracker + 1
mySheetNames(ScreenTracker) = .List(ScreenCounter - 1)
Sheet(ScreenCounter) = mySheetNames(ScreenTracker)
End If
Next ScreenCounter
End With

With Me.ListBox2
For ScreenCounter2 = 1 To .ListCount
If .Selected(ScreenCounter2 - 1) Then
ScreenTracker2 = ScreenTracker2 + 1
mySheetNames2(ScreenTracker2) = .List(ScreenCounter2 - 1)
Sheet2(ScreenCounter2) = mySheetNames2(ScreenTracker2)
MsgBox (ScreenCounter2 & ScreenTracker2)
End If
Next ScreenCounter2
End With



--
I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed


"Per Jessen" wrote:

Hi

Showing the code used to populate the list boxes will enable us to see
what
is happening.

Regards,
Per

"fishonspeed" skrev i meddelelsen
...
I have two list boxes that should both show the exact same thing. So I
used
the exact same code for both boxes just with different variables that
have
the exact same values.

The problem is that only the first list box shows anything. And even if
I
take the code for ListBox1 out and leave everything for ListBox2 in the
selections still show up in ListBox1. If I have the code for both boxes
written, the selections still only show in ListBox1 and ListBox2 is
blank.

Any ideas as to why this may be happening?
--
I dispise your poor English and inability to use punctuation correctly
...
or at all.
~FishOnSpeed





Per Jessen

Confused about the ListBoxes.
 
Okay, I don't see that your code is adding anything to the list boxes. Are
you sure that it's the code that populates Listbox1?

If you are working with a UserForm use the code below to populate the list
boxes with sheet names. If your list boxes is on a worksheet you can not use
Sub UserForm_Initialize, but the code within the sub will work.

Private Sub UserForm_Initialize()
For sh = 1 To ThisWorkbook.Sheets.Count
Me.ListBox1.AddItem Sheets(sh).Name
Me.ListBox2.AddItem Sheets(sh).Name
Next
End Sub

Best regards,
Per

"fishonspeed" skrev i meddelelsen
...
Their counting the sheets and placing the sheet names in a list that is
then
displayed in a list box. I'm just confused as to why one works while the
other doesn't. The second one doesn't even execute. I've tried placing
MsgBoxes in several places throughout the second procedure and nothing
happens. The program completely skips that chunk of code.

I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed


"Per Jessen" wrote:

Hi again

I'm not sure what you are trying to to with this code part. What are the
variables refering to ?

Regards,
Per

"fishonspeed" skrev i meddelelsen
...
Ah. That is true.
Here it is:

With Me.ListBox1
For ScreenCounter = 1 To .ListCount
If .Selected(ScreenCounter - 1) Then
ScreenTracker = ScreenTracker + 1
mySheetNames(ScreenTracker) = .List(ScreenCounter - 1)
Sheet(ScreenCounter) = mySheetNames(ScreenTracker)
End If
Next ScreenCounter
End With

With Me.ListBox2
For ScreenCounter2 = 1 To .ListCount
If .Selected(ScreenCounter2 - 1) Then
ScreenTracker2 = ScreenTracker2 + 1
mySheetNames2(ScreenTracker2) = .List(ScreenCounter2 -
1)
Sheet2(ScreenCounter2) = mySheetNames2(ScreenTracker2)
MsgBox (ScreenCounter2 & ScreenTracker2)
End If
Next ScreenCounter2
End With



--
I dispise your poor English and inability to use punctuation correctly
...
or at all.
~FishOnSpeed


"Per Jessen" wrote:

Hi

Showing the code used to populate the list boxes will enable us to see
what
is happening.

Regards,
Per

"fishonspeed" skrev i meddelelsen
...
I have two list boxes that should both show the exact same thing. So
I
used
the exact same code for both boxes just with different variables
that
have
the exact same values.

The problem is that only the first list box shows anything. And even
if
I
take the code for ListBox1 out and leave everything for ListBox2 in
the
selections still show up in ListBox1. If I have the code for both
boxes
written, the selections still only show in ListBox1 and ListBox2 is
blank.

Any ideas as to why this may be happening?
--
I dispise your poor English and inability to use punctuation
correctly
...
or at all.
~FishOnSpeed







All times are GMT +1. The time now is 01:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com