![]() |
Please help...formula problems
Thanks for the answer Bob but I still can't get it to work.
It's probably just me. I don't understand the code. It's column H that we're putting initials of whoever enters the information into the spreadsheet in and column I that we want the date to automatically appear in. We managed to get it to automatically put in a date, but everytime a new cell in column H was filled the date went into the next cell in I but it changed all the dates in that column to match. I'm hoping that it is possible to sort this out and I REALLY appreciate your help. Thanks, Nikki "Bob Phillips" wrote: Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "H1:H10" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Offset(0, 1).Value = Date .Offset(0, 1).NumberFormat = "dd mmm yyyy" End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "nikkiamii" wrote in message ... I am trying to get excel to automatically insert a date in a cell when the cell next to it is filled. I've tried using the IF and NOW functions but I don't think I can use them together. Please help because I don't seem to be able to find an answer anywhere! |
Please help...formula problems
Have you tried a basic cell formula like this one?
=IF((cellreference)<"",NOW(),"") That will return a date in the cell based on whatever cell you reference. You just need to format the cell to a date format in the cell that you have the formula. "nikkiamii" wrote: Thanks for the answer Bob but I still can't get it to work. It's probably just me. I don't understand the code. It's column H that we're putting initials of whoever enters the information into the spreadsheet in and column I that we want the date to automatically appear in. We managed to get it to automatically put in a date, but everytime a new cell in column H was filled the date went into the next cell in I but it changed all the dates in that column to match. I'm hoping that it is possible to sort this out and I REALLY appreciate your help. Thanks, Nikki "Bob Phillips" wrote: Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "H1:H10" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Offset(0, 1).Value = Date .Offset(0, 1).NumberFormat = "dd mmm yyyy" End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "nikkiamii" wrote in message ... I am trying to get excel to automatically insert a date in a cell when the cell next to it is filled. I've tried using the IF and NOW functions but I don't think I can use them together. Please help because I don't seem to be able to find an answer anywhere! |
Please help...formula problems
Yes we tried that but everytime a new cell in the column was filled all the
cells with the date or now formula in them changed to the current date and time. "Dave at TAX" wrote: Have you tried a basic cell formula like this one? =IF((cellreference)<"",NOW(),"") That will return a date in the cell based on whatever cell you reference. You just need to format the cell to a date format in the cell that you have the formula. "nikkiamii" wrote: Thanks for the answer Bob but I still can't get it to work. It's probably just me. I don't understand the code. It's column H that we're putting initials of whoever enters the information into the spreadsheet in and column I that we want the date to automatically appear in. We managed to get it to automatically put in a date, but everytime a new cell in column H was filled the date went into the next cell in I but it changed all the dates in that column to match. I'm hoping that it is possible to sort this out and I REALLY appreciate your help. Thanks, Nikki "Bob Phillips" wrote: Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "H1:H10" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Offset(0, 1).Value = Date .Offset(0, 1).NumberFormat = "dd mmm yyyy" End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "nikkiamii" wrote in message ... I am trying to get excel to automatically insert a date in a cell when the cell next to it is filled. I've tried using the IF and NOW functions but I don't think I can use them together. Please help because I don't seem to be able to find an answer anywhere! |
Please help...formula problems
Ok, then the VB code should work like this:
Private Sub Worksheet_Change(ByVal Target As range) With Target If Cells(.Column, 1).Value = "" Then Cells(.Row, 2).Value = Date End If End With End Sub The .column, # and .row, # should be chaged to reflect which column # your entry and result should go in (e.g., .column, 1 is column A, .row, 1 is also column A). This should work. "nikkiamii" wrote: Yes we tried that but everytime a new cell in the column was filled all the cells with the date or now formula in them changed to the current date and time. "Dave at TAX" wrote: Have you tried a basic cell formula like this one? =IF((cellreference)<"",NOW(),"") That will return a date in the cell based on whatever cell you reference. You just need to format the cell to a date format in the cell that you have the formula. "nikkiamii" wrote: Thanks for the answer Bob but I still can't get it to work. It's probably just me. I don't understand the code. It's column H that we're putting initials of whoever enters the information into the spreadsheet in and column I that we want the date to automatically appear in. We managed to get it to automatically put in a date, but everytime a new cell in column H was filled the date went into the next cell in I but it changed all the dates in that column to match. I'm hoping that it is possible to sort this out and I REALLY appreciate your help. Thanks, Nikki "Bob Phillips" wrote: Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "H1:H10" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Offset(0, 1).Value = Date .Offset(0, 1).NumberFormat = "dd mmm yyyy" End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "nikkiamii" wrote in message ... I am trying to get excel to automatically insert a date in a cell when the cell next to it is filled. I've tried using the IF and NOW functions but I don't think I can use them together. Please help because I don't seem to be able to find an answer anywhere! |
All times are GMT +1. The time now is 03:25 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com