Objective: To pass multi-selected items to other macro to perform routine.
Known issues: Sometimes I have one item selected sometimes 20, but in all cases I need the name of the item selected to pass to the next routine and execute appropriately.
NOTE: each selected item should be treated seperately.
Code from mutli-list box:
Code from command button on multi-list form:
Where Items need to pass to (items in red):
Known issues: Sometimes I have one item selected sometimes 20, but in all cases I need the name of the item selected to pass to the next routine and execute appropriately.
NOTE: each selected item should be treated seperately.
Code from mutli-list box:
Code:
Private Sub UserForm_Activate()
Dim i As Worksheet
For Each i In ActiveWorkbook.Worksheets
If i.Name Like "*Pricing[ ]#*" Then
ListBox1.AddItem i.Name
End If
Next i
End Sub
Code from command button on multi-list form:
Code:
Private Sub CommandButton1_Click()
Dim text As String
Dim i As Integer
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
text = text & Me.ListBox1.List(i) & vbNewLine
End If
Next i
MsgBox "Items you selected: " & vbNewLine & text
GetSelectedItemsText = text
Unload Me
Call Create_SPAsummary
Call Move_SPApricing
Call Copy_Facility
End Sub
Where Items need to pass to (items in red):
Code:
[Sub Copy_Facility()
'
' Copy_Facility: move data from individual selected pricing sheets to summary page
'
'
Application.ScreenUpdating = False
'copy sheet name to summary
Sheets("[COLOR=#ff0000]ABC Pricing 05-21-2013[/COLOR]").Select
Range("A1").Select
Selection.Copy
Sheets("SPA_Summary").Select
Range("C5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("C:C").EntireColumn.AutoFit
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("B5").Select
'copy target percentage
Sheets([COLOR=#ff0000]"ABC Pricing 05-21-2013")[/COLOR].Select
Range("G3").Select
Selection.Copy
Sheets("SPA_Summary").Select
Range("C6").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Tulane Unive Pricing 05-21-2013").Select
Range("G4").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SPA_Summary").Select
Range("C7").Select
Selection.PasteSpecial Paste:=xlPasteFormulasAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets[COLOR=#ff0000]("ABC Pricing 05-21-2013").[/COLOR]Select
Range("G5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SPA_Summary").Select
Range("C8").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets[COLOR=#ff0000]("ABC Pricing 05-21-2013").Se[/COLOR]lect
Range("G6").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SPA_Summary").Select
Range("C9").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("[COLOR=#ff0000]ABC Pricing 05-21-2013").[/COLOR]Select
Range("G7").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SPA_Summary").Select
Range("C10").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("[COLOR=#ff0000]ABC Pricing 05-21-2013")[/COLOR].Select
Range("G8").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SPA_Summary").Select
Range("C11").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("[COLOR=#ff0000]ABC Pricing 05-21-2013")[/COLOR].Select
Range("G9").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SPA_Summary").Select
Range("C12").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Columns("C:C").Select
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("C5").Select
Selection.Font.Bold = True
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("B4").Select
Application.ScreenUpdating = True
End Sub