V
VBA_Newbie79
I am having difficulty determining which decision statement is the best for
my situation. What the code is supposed to do, is loop through the multiple
choices made by a user in a userform listbox and perform one or more of the
listed statements depending on the choice. Below is my attempt at using the
Select Case statement, but I don't think Select Case will allow more than one
case to be true. As you can see, I am in desperate need of your help.
Thanks in advance!
For i = 0 To Change_Region.ListBox1.ListCount - 1
If Change_Region.ListBox1.Selected(i) = True Then
Change_Region.Hide
Application.ScreenUpdating = False
Select Case ListBox1.Selected(i)
Case Is = 0
Application.Goto ("Africa")
Selection.Copy
Worksheets("CAPSDATA").Activate
Worksheets("CAPSDATA").Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Worksheets("CAPSDATA").Range("A1").Select
Case Is = 1
Application.Goto ("Central_Europe")
Selection.Copy
Worksheets("CAPSDATA").Activate
Worksheets("CAPSDATA").Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Worksheets("CAPSDATA").Range("A1").Select
Case Is = 2
Application.Goto ("Fmr_Soviet_Union")
Selection.Copy
Worksheets("CAPSDATA").Activate
Worksheets("CAPSDATA").Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Worksheets("CAPSDATA").Range("A1").Select
Case Is = 3
Application.Goto ("Indian_Subcontinent")
Selection.Copy
Worksheets("CAPSDATA").Activate
Worksheets("CAPSDATA").Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Worksheets("CAPSDATA").Range("A1").Select
End Select
End If
Next i
my situation. What the code is supposed to do, is loop through the multiple
choices made by a user in a userform listbox and perform one or more of the
listed statements depending on the choice. Below is my attempt at using the
Select Case statement, but I don't think Select Case will allow more than one
case to be true. As you can see, I am in desperate need of your help.
Thanks in advance!
For i = 0 To Change_Region.ListBox1.ListCount - 1
If Change_Region.ListBox1.Selected(i) = True Then
Change_Region.Hide
Application.ScreenUpdating = False
Select Case ListBox1.Selected(i)
Case Is = 0
Application.Goto ("Africa")
Selection.Copy
Worksheets("CAPSDATA").Activate
Worksheets("CAPSDATA").Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Worksheets("CAPSDATA").Range("A1").Select
Case Is = 1
Application.Goto ("Central_Europe")
Selection.Copy
Worksheets("CAPSDATA").Activate
Worksheets("CAPSDATA").Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Worksheets("CAPSDATA").Range("A1").Select
Case Is = 2
Application.Goto ("Fmr_Soviet_Union")
Selection.Copy
Worksheets("CAPSDATA").Activate
Worksheets("CAPSDATA").Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Worksheets("CAPSDATA").Range("A1").Select
Case Is = 3
Application.Goto ("Indian_Subcontinent")
Selection.Copy
Worksheets("CAPSDATA").Activate
Worksheets("CAPSDATA").Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Worksheets("CAPSDATA").Range("A1").Select
End Select
End If
Next i