MS Excel Time in specific cell when A1 contains data

5pds

Board Regular
Joined
Mar 24, 2009
Messages
65
Aim is when a vehicle has been assigned to collection, time of entry appears in Load cell coresponding with vehicle eg.e vehicle 1 'A1' = load 1 'B1'. I can get the exact time to appear in the cell currently but when I try to assign a second truck, the load 2 'B2' cell AND the load 1 'B1'. Im sure that there is an easy way to do this but i just cant figure it out. Can someone please help me out. Can i disable the cell that is updating?

I have the spreadseet and if anyone thinks that they can help i can sent it through

My knowledge of these things are limited so excuse the naivety
 
Tried to use the above as a bit of practice and run into a "End if without Block if" problem
Trying to make it so that if I enter anything in Column H (8) the date and time appears in cell A3
Code used

[
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 8 Then Exit Sub
Range("$a$3") = Now
End If
[\CODE]

Also where did i go wrong with the code brackets?
Thjanks

Pedro
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Pedro, you are right. The End If should be removed. I had adjusted a previous code and forgot to remove it. You have [
Code:
 instead of [code]
lenze
 
Upvote 0
Thanks Lenze,
I was not right I just discovered that I got the error message.
However, now I get the message "compile error expected end sub"
Thanks for pointing out the bracket which I also had a back slash in error

Offending code

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 8 Then Exit Sub
Range("$a$3") = Now

Pedro
 
Upvote 0
Sorted thanks

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 7 Then Exit Sub
Range("$a$3") = Now
 End Sub

Pedro
 
Upvote 0
OK. I know you're new to the board, so don't take this wrong. It is, however, usually best to describe the whole problem up front in the original post.(ie What you want to do) It takes more up-front work on your part, but you will tend to get faster and better results.
Anyway. Can you be more specific as to your needs. What happens when a cell in Column "G" is changed? Column "H"?, Etc. The code is simple, but you need to provide as much details as possible.
lenze


Right i will start from the top. I have 4 cells that i require a time to appear in when a value is entered into g7,h7,i7,j7,k7. These entries should correspond with p7,q7,r7,s7,t7.

E.g. When i enter a value (54) into g7, i want the exact time to apprear in p7 and when i enter a value into h7, i want an exact time to appear in q7.....and so on.

I plan to do this for the whole columns mentioned from 7 down to 154.

Does this make sense.

Again sorry for the naivety.:stickouttounge:

Paul
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("G7:K154")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Offset(, 9).Value = Now
Application.EnableEvents = True
End Sub
 
Upvote 0
Still no joy. Maybe i am doing something wrong in the process?

Any other suggestions that you may have?

Thanks again
 
Upvote 0
Make sure that macros are enabled: Tools > Macro > Security.

Make sure that events are enabled: in the code window press CTRL + G then in the Immediate Window type

Application.EnableEvents=True

and press Enter.
 
Upvote 0
I am no expert but like to experiment with suggestions made on forum.

This is what I did to get it to work.
Opened workbook , after copying code as suggested.
On the sheet Tab (sheet 1) Right click and select View Code .
When the VBA window opened , made sure it was showing Sheet 1 at top and to the right under sheet headed Worksheet Change I pasted in the code.

Then hit Alt+Q and this took me back to sheet 1.
Entered data in cells G7:K7 and the date and time showed up in cells P7:Q7.

Try that

Pedro
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top