My eventual goal is to create a function that will scroll through every worksheet displaying them 1 at a time then being able to select one. -
That being said here is where I currently stand: I have a function that gives me a comma seperated string of the worksheet names, so I decided to add a section that would display the current worksheet and wait for my entry in the inputbox before continuing to the next worksheet, but for some reason when I try to select the worksheet I bounce out of the function.
Any Ideas?
That being said here is where I currently stand: I have a function that gives me a comma seperated string of the worksheet names, so I decided to add a section that would display the current worksheet and wait for my entry in the inputbox before continuing to the next worksheet, but for some reason when I try to select the worksheet I bounce out of the function.
Any Ideas?
Code:
Function GetwsNames(sWBName) As String
'
' Return a comma seperated string of all the Worksheet Names in the Workbook
'
Dim answer As String
Dim ws As Worksheet
Dim sWSNames As String
With Workbooks.Open(sWBName)
For Each ws In .Sheets
If sWSNames = "" Then
sWSNames = ws.Name
Else: sWSNames = sWSNames & "," & ws.Name
End If
'the following should display each worksheet as it is selected
'I have tried many combinations of code to get this to work
'and am now trying in round about ways
answer = ws.Name
Worksheets(answer).Cells(1, 1).Activate
Range("A1").Select
answer = Application.InputBox("Press any key", "Waiting", Type:=2)
Next
End With
GetwsNames = sWSNames
End Function