Question How to find new worksheet in workbook

liam1289

New Member
Joined
Apr 27, 2011
Messages
16
iv a work book with 5 worksheets mon-fri in it. i have a bottom to ask the user which day they would like to see but im having a problem with the find command for different sheets in abook i tried using the find command but it didnt work for me...can anyone help please
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi

VBA wise you just need to activate the given worksheet:

Rich (BB code):
Worksheets("Mon").Activate

Change the bit in red to whatever the applicable sheet name is.
 
Upvote 0
Hi there,
Sorry for highjacking this thread but I have a similar issue with my vba macro and hoped that maybe it is relevant to this query:
I have a standard macro and I am trying to insert a Form which forces the user to select a User name before continuing with the macro.

My user selects a row in the first worksheet (this holds lots of variable information) then launches the macro.
A Login Form appears for the user to select a UserName from another sheet.
Then the macro continues with the first sheet and completes the work.

However, it does not work using the '.activate' option as I had hoped.
worksheets("username").activate (set in the first Sub)
worksheets("sources").activate (set in the following Sub)

It gives me a run-time error '9'
Subscript out of range

Any idea?

Thanks,
 
Upvote 0
Subscript out of range is telling you you don't have a worksheet by the name of "Username" or "Sources" (depending on which line actually bugs out) in the active workbook at the time the code is executing.
 
Upvote 0
thanks for replying.but i will have an inputbox requesting the user to pick which day they wish to view..so do i just say
worksheets(inputboxname).activate?
 
Upvote 0
You could do something like this:

Code:
Dim mySht As String
Dim ws As Worksheet

mySht = InputBox("What sheet do you want to choose?")

On Error Resume Next
Set ws = Sheets(mySht)
On Error Goto 0

If Not ws Is Nothing Then
  ws.Activate
Else
  MsgBox "No valid sheet selected!"
End If
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,672
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top