Input Username and Password in Excel for Oracle DB

This code will capture a username and password on open, this will go hand in hand with the connection to an oracle database.

 

In “This Workbook” paste this code.

 

As Always parts in bold  will need to change for your own use.

 

Private Sub Workbook_Open()

Dim inputDataN As String

Dim inputDataP As String

Dim UserN As String

With Worksheets(“Sheet3“)

.Range(“E1“).ClearContents

.Range(“E2“).ClearContents

End With

inputDataN = Application.InputBox(“Enter your Username:”, “Input Box Text”, Type:=2)

Worksheets(2).Range(“E1“).Value = inputDataN

inputDataP = Application.InputBox(“Enter your Password:”, “Input Box Text”, Type:=2)

Worksheets(2).Range(“E2“).Value = inputDataP

UserN = Sheets(“Sheet3“).Range(“E1“)

 

If UserN = (“SuperUser“) Then

Sheets(“Sheet3”).Visible = True

Else

Sheets(“Sheet3”).Visible = xlVeryHidden

End If

End Sub

 

The last part of this code will unhide Sheet 3, due to it containing sencesitive information we do not want all users to beable to see or amend this sheet so its classed as “Very Hidden” by entering the username of “SuperUser” it will automatically unhide the sheet for amendments.