Novice q: allow user to select worksheet in middle of macro
Hi canary2211.
In Excel 2003 I have first made an userform with a combobox and a
commandbutton
The form is named frmCanary2211
The combobox is named "cboSheets"
The commandbutton is named "cmdProces"
In the form this code
' Start on code
Option Explicit
Private Sub cmdProces_Click()
Dim strName As String
Dim intIndex As Integer
strName = cboSheets.Text
intIndex = cboSheets.ListIndex
Worksheets(strName).Activate
Range("A1").Select
ActiveSheet.Paste
If cboSheets.ListCount 1 Then
cboSheets.RemoveItem intIndex
cboSheets.ListIndex = 0
Else
MsgBox "Al sheets done"
Me.Hide
End If
End Sub
Private Sub UserForm_Activate()
Dim shtLoop As Worksheet
Dim intLoop As Integer
intLoop = 0
For Each shtLoop In ThisWorkbook.Worksheets
If shtLoop.Name < "Index" Then
intLoop = intLoop + 1
Me.cboSheets.AddItem shtLoop.Name
End If
Next
End Sub
' end of code
Second I created a small starter macro:
Sub canary2211()
Selection.Copy
frmCabary2211.Show
End Sub
To use it, just select the cells to be copied and hit [Alt][F8].
select canary2211 and the form will be shown.
HTH,
Wouter
|