PC Review


Reply
Thread Tools Rate Thread

How do I find out what cell reference was selected - not the value

 
 
LuvMyTennis
Guest
Posts: n/a
 
      13th Dec 2008
Hi, I am trying to create a timesheet, and when the user inputs data I want
to write some VBA code to check it and also apply some conditional formatting.

B C D E
F G
1 Mon Tue Wed Thu
Fri
2 start 7:00 am 6:45 am
3 end 12:30 pm
4 subtotal 5:30

my issues:

(1) How do I know what cell reference the user has just entered into and
how do I pass that cell reference into VBA?
For instance, if the user has just entered "6:45 am" into D2, how do
I pass that cell reference into VBA?

I need to do this to then perform some checks eg:

(a) if user starts before 7:00 am then flag (highlight) the cell red -
because they can't start before 7:00 am. some code I've done so far for this
is:


inputValue.NumberFormat = "h:mm am/pm"
If inputValue.Text < "7:00 AM" Then
inputValue.Interior.Color = RGB(255, 255, 0)

(b) Is this the best one to put all this code in - eg to find out which
cell reference was entered into and to pass this into VBA code - eg this
followingone:

Private Sub Worksheet_Change(ByVal Target As Range)

Your assistance is greatly appreciated.


 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      13th Dec 2008
try
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Text < "7:00 AM" Then
Target.Interior.Color = RGB(255, 255, 0)
End If
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"LuvMyTennis" <(E-Mail Removed)> wrote in message
news:B82170C0-1B24-455A-A703-(E-Mail Removed)...
> Hi, I am trying to create a timesheet, and when the user inputs data I
> want
> to write some VBA code to check it and also apply some conditional
> formatting.
>
> B C D E
> F G
> 1 Mon Tue Wed Thu
> Fri
> 2 start 7:00 am 6:45 am
> 3 end 12:30 pm
> 4 subtotal 5:30
>
> my issues:
>
> (1) How do I know what cell reference the user has just entered into and
> how do I pass that cell reference into VBA?
> For instance, if the user has just entered "6:45 am" into D2, how
> do
> I pass that cell reference into VBA?
>
> I need to do this to then perform some checks eg:
>
> (a) if user starts before 7:00 am then flag (highlight) the cell red -
> because they can't start before 7:00 am. some code I've done so far for
> this
> is:
>
>
> inputValue.NumberFormat = "h:mm am/pm"
> If inputValue.Text < "7:00 AM" Then
> inputValue.Interior.Color = RGB(255, 255, 0)
>
> (b) Is this the best one to put all this code in - eg to find out
> which
> cell reference was entered into and to pass this into VBA code - eg this
> followingone:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> Your assistance is greatly appreciated.
>
>


 
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
How to get the cell reference of the value selected from name list YY san. Microsoft Excel Worksheet Functions 3 7th Mar 2009 06:52 PM
A formula for displaying the cell reference of the selected cell Emlou85 via OfficeKB.com Microsoft Excel Misc 3 19th Mar 2006 03:54 PM
Display the cell reference of the cell that is currently selected. Emlou85 via OfficeKB.com Microsoft Excel Worksheet Functions 5 18th Mar 2006 10:29 AM
How do I reference the last row and selected cell/s? =?Utf-8?B?Um9iZXJ0?= Microsoft Excel Worksheet Functions 2 22nd Oct 2004 03:13 AM
How to reference the currently selected cell in VBA. beeawwb Microsoft Excel Misc 1 18th Mar 2004 05:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:39 PM.