Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code not executing 1

Status
Not open for further replies.

MarkBeck

Technical User
Mar 6, 2003
164
CA
Hi

I have a sheet that hides all but the Welcome Sheet on Opening. Then people enter a user name & Password, and it makes their sheet visible.

I just now added a sheet called "Inv Usage" (Or sheet6), and i would like to display it ALL the time. So whoever opens the workbook see THEIR sheet plus this one. I added a piece of code at the end like this;

"Sheets("Inv Usage").Activate"

Its not working. I have also tried;

"With Sheets("Inv Usage")
.Visible = xlSheetVisible
.Activate
End With"

Also not working.

Here is my entire code;

Sub OpenTimecard()
Sheets("Welcome").Activate
If Range("SheetSelector") = "" Then
MsgBox ("Please enter Username & Password!")
Else
If Range("SheetSelector") = "Error!" Then
MsgBox ("Username Password error!")
Else
With Sheets(Range("SheetSelector").Value) 'Index+Match result of WS name
.Visible = xlSheetVisible
.Activate
End With
End If
End If
ClearWelcome 'Clears UserName & Password
Sheets("Inv Usage").Activate
End Sub

What am i doing wrong? and also, is this code cumbersome?
 




Code:
With Sheets("Inv Usage")
     .Visible = xlSheetVisible
     .Activate
 End With
will work if your sheet is names Inv Usage. BTW, this code is NOT in your "entire code."

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 



Try this...
Code:
Sub OpenTimecard()
    Sheets("Welcome").Activate
    Select Case Range("SheetSelector").Value
        Case ""
            MsgBox ("Please enter Username & Password!")
        Case "Error!"
            MsgBox ("Username Password error!")
        Case Else
            With Sheets(Range("SheetSelector").Value) 'Index+Match result of WS name
                .Visible = xlSheetVisible
                .Activate
            End With
            With Sheets("Inv Usage")
                 .Visible = xlSheetVisible
                 .Activate
             End With
    End Select
    ClearWelcome   'Clears UserName & Password
End Sub

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Works a treat! Thank you skip. You are a star!

I would love to become more proficient in VB. Is there a book you could recommend? I would be bugging less people here.

I am in fiscal accounting, and act a financial controller to various companies. I feel that VBA would increase productivity for me a lot. (I will devote 4 hrs per week. That’s Hrs 55 to 58....)

Mark
 



Just check them out at a bookstore. Each person learns differently. I'v always liked John Walkenback's books.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top