PC Review


Reply
Thread Tools Rate Thread

Data Validation Navigation - only once variable

 
 
bluegrassstateworker
Guest
Posts: n/a
 
      1st Aug 2006
I have the below code in use (thanks, L. Howard Kittle ) and noticed
that while my navigation is correct, every time I hit the enter key in
subsequent cells, I am annoyingly navigated to the RFP worksheet (which
I only need to do so once). The code is below:
*********
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("E23").Value = "RFP" Then
Sheets("RFP").Activate
Sheets("RFP").Range("A1").Select
End If
End Sub
*********
My thought was to define a variable and include in the If statement to
read something like:
IF Range(E23) .... AND VARIABLESET=T Then
But, since I would initialize the variable, it would be reset every
time the spreadsheet is open. Anyone have a thought to keep this
routine from running after a value is inserted?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIEh1dGNoaW5z?=
Guest
Posts: n/a
 
      1st Aug 2006
Add a VBA module to your workbook. In it, add:

Option Explicit
Global BeenThereAlready As Boolean

In the ThisWorkbook module of your workbook, add:

Private Sub Workbook_Open()
BeenThereAlready = False
End Sub

Finally, change the Worksheet_Change event code you already have to the
following:

Private Sub Worksheet_Change(ByVal Target As Range)
If (Range("E23").Value = "RFP") And _
(BeenThereAlready = False) Then
Sheets("RFP").Activate
Sheets("RFP").Range("A1").Select
BeenThereAlready = True
End If
End Sub

This will take the user to the RFP sheet only the first time he/she enters
RFP in cell E23.

Hope this helps,

Hutch

"bluegrassstateworker" wrote:

> I have the below code in use (thanks, L. Howard Kittle ) and noticed
> that while my navigation is correct, every time I hit the enter key in
> subsequent cells, I am annoyingly navigated to the RFP worksheet (which
> I only need to do so once). The code is below:
> *********
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Range("E23").Value = "RFP" Then
> Sheets("RFP").Activate
> Sheets("RFP").Range("A1").Select
> End If
> End Sub
> *********
> My thought was to define a variable and include in the If statement to
> read something like:
> IF Range(E23) .... AND VARIABLESET=T Then
> But, since I would initialize the variable, it would be reset every
> time the spreadsheet is open. Anyone have a thought to keep this
> routine from running after a value is inserted?
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable data validation Mika Microsoft Excel Discussion 6 15th Sep 2011 10:17 AM
variable in data validation Mike.ONeal Microsoft Excel Worksheet Functions 4 1st May 2009 06:58 PM
data validation: variable drop down =?Utf-8?B?Q0RNQU4=?= Microsoft Excel Misc 2 29th Jan 2007 07:34 AM
navigation and validation on continous form Jhon Hendri via AccessMonster.com Microsoft Access Form Coding 0 7th Apr 2005 02:05 PM
When pasting data into a column with data validation I lose validation check Brad Microsoft Excel Misc 5 17th Apr 2004 01:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:37 AM.