Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Password required to select value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Graeme - 29 Feb 2008 16:35 GMT
In cell b4, I have a drop-down box with 5 salary bands: A, B, C, D and E.  I
also have a lookup table with associates a salary with each of these bands,
and this value is place in cell b5.  I would like anyone to be able to select
A, B or C and see these salaries, but only people with a password to be able
to select D or E, and therefore see these salaries. I was hoping there was an
efficient way of doing this using Worksheet_Change(ByVal Target As Range) and
an Inputbox.  Thank you.
Libby - 01 Mar 2008 11:16 GMT
Hi Graeme,

Is the dropdown box a combobox or data validation?

For data validation try this, although if it's a combobox it might be better
to load it every time the workbook is opened with the options being dependant
on who is logged onto the computer. That way if they disable macros they
won't be able to select the c/d without invoking the password.

Public myval 'value selected
Public hasRun As Boolean 'to prevent the inputbox recurrng

Private Sub Worksheet_Change(ByVal Target As Range)
 If hasRun = False Then
   Select Case Range("B4").Text
     Case "C", "D"
       myval = Range("B4") 'remember what was chosen
       hasRun = True
       Range("B4") = ""  'remove the contents of B4
       If Application.InputBox("enter password") = "password" Then
         Range("B4") = myval  'restore the chosen value
       Else
         Range("B4") = "" 'leave blank
       End If
       hasRun = False
   End Select
 End If
End Sub

> In cell b4, I have a drop-down box with 5 salary bands: A, B, C, D and E.  I
> also have a lookup table with associates a salary with each of these bands,
[quoted text clipped - 3 lines]
> efficient way of doing this using Worksheet_Change(ByVal Target As Range) and
> an Inputbox.  Thank you.
Graeme - 04 Mar 2008 14:40 GMT
Libby,

Thank you.  I was using a drop-down box, and your code worked perfectly.

Graeme

> Hi Graeme,
>
[quoted text clipped - 32 lines]
> > efficient way of doing this using Worksheet_Change(ByVal Target As Range) and
> > an Inputbox.  Thank you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.