If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > A new challenge

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-20-04, 21:18
qimel qimel is offline
Registered User
 
Join Date: Feb 2004
Location: USA - California
Posts: 21
Talking A new challenge

How can I use an "if" statement or some other way to calculate a formula when a cell value changes? Something like: =if(A1 changes value,(today), no change) This formula would reside in cell C1 and would display todays date in cell C1 if the value in A1 has changed today. If it has not changed today, it would leave the previous date (whatever it would happen to be from the last time the value in A1 has changed) in the cell. The value in A1 would be changed by typing the value directly in A1. This sounded simple.....but now I'm can't find a function to detect the change in value.....any help out there please?

Thank you.....Melinda
Reply With Quote
  #2 (permalink)  
Old 02-22-04, 15:26
qimel qimel is offline
Registered User
 
Join Date: Feb 2004
Location: USA - California
Posts: 21
I lost the reply.....

Something happenned....I wanted to reply to the person who replied to me, and somehow I lost the post. I am new to VBA and I can't get the code to work. The cells that are changing value are in column G. The current date is in column K. I want the date in column K to change as the value in column G changes.....or put the new date in column L. The rows are 3 through 2950. How do I use the code with that range?
Thank you,
Melinda
Reply With Quote
  #3 (permalink)  
Old 02-22-04, 15:49
bmacr bmacr is offline
Registered User
 
Join Date: Feb 2004
Location: Canada
Posts: 133
Sorry about that, I discovered my mistake and thought I could quietly delete the post before someone read it! Try this code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 And (Target.Row > 2 And Target.Row < 2351) Then
Cells(Target.Row, 11) = Now
End If
End Sub

That should do the trick.
Reply With Quote
  #4 (permalink)  
Old 02-22-04, 16:23
qimel qimel is offline
Registered User
 
Join Date: Feb 2004
Location: USA - California
Posts: 21
almost there.....

Originally posted by bmacr [/i]
Sorry about that, I discovered my mistake and thought I could quietly delete the post before someone read it! Try this code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 And (Target.Row > 2 And Target.Row < 2351) Then
Cells(Target.Row, 11) = Now
End If
End Sub

That should do the trick.


No problem....thought I just messed things up. That works execpt it puts the date in one cell only. I want it to put the date in the corresponding row with the value change. If the values changed on row 1100, I want the date to appear in row 1100.

Thank you!!!
Reply With Quote
  #5 (permalink)  
Old 02-22-04, 16:34
bmacr bmacr is offline
Registered User
 
Join Date: Feb 2004
Location: Canada
Posts: 133
Hmm... on my machine if I change a value in G20, today's date appears in K20. What cell does it appear in on yours?
Reply With Quote
  #6 (permalink)  
Old 02-22-04, 16:37
qimel qimel is offline
Registered User
 
Join Date: Feb 2004
Location: USA - California
Posts: 21
got it now...had a typo. I put column instead of row in that last bit. Thank you so much!!!!
Reply With Quote
  #7 (permalink)  
Old 02-22-04, 16:41
bmacr bmacr is offline
Registered User
 
Join Date: Feb 2004
Location: Canada
Posts: 133
My pleasure. Glad you got it working.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On