Hi Valeria,
The code with using Input box would be...
Sub Test()
Dim wkb As Workbook
Dim strWkbName
Dim strActivate As String
For Each wkb In Workbooks
strWkbName = strWkbName & wkb.Name & vbLf
Next
strActivate = Application.InputBox _
(strWkbName & "Which workbook do you want to activate?")
On Error GoTo Terminate
With Windows(strActivate)
.Visible = True
.Activate
End With
Exit Sub
Terminate:
MsgBox Err.Number & ":" & Err.Description
End Sub
But I think you don't have to ACTIVATE workbook, just specify the workbook
that you want, like this.
Just my opinion, ListBox or Combobox is better than inputBox. (You don't
have to type, just can select names)
Sub Test2()
Dim wkb As Workbook
Dim strWkbName
Dim strActivate As String
For Each wkb In Workbooks
strWkbName = strWkbName & wkb.Name & vbLf
Next
strActivate = Application.InputBox _
(strWkbName & "Which workbook do you want to activate?")
On Error GoTo Terminate
YourMacro Workbooks(strActivate)
Exit Sub
Terminate:
MsgBox Err.Number & ":" & Err.Description
End Sub
Sub YourMacro(ByVal wkb As Workbook)
wkb.Sheets(1).Cells(1, 1).Value = "something"
End Sub
--
Kind Regards
Colo
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Colo of 'The Road of The Cell Masters'
URL:
http://www.interq.or.jp/sun/puremis/colo/CellMastersLink.htm
mailto:
[email protected]
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/