Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Dates and comments

When a date is placed in any cell D, I would like either:
1) a comment to automatically be accociated to cell F on the same row with a
date displayed which will be the date from D + 14, OR
2) When the cell in F has focus, the date (D + 14) appears in a pre
determined cell at the top of the page, F2 for instance.

Any ideas?
--
Traa Dy Liooar

Jock
  #2   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default Dates and comments

Unfortunately I do not have hard code to give you, but if you look into
events that can occur on a worksheet, then what you would want to do is
capture a cell change event.

If the change occurs in a cell that is in column D, then check to see if it
is a date or contains a date (Depending on what data you expect in the cell.
I.e., if you expect someone to type "This will be performed on 01/01/10" then
all you want from the text is the date.

If that is true, then assign the appropriate "object" (You mentioned a
comment, though not sure if you are referring to a little popup comment, or
just a string of text like "This is due on 01/15/10") the date of column D
incremented by 14 days. I don't recall the function name, but there is a
date option where you input the month, day, and year separately and it
provides a date code. I recommend this feature rather than just incrementing
the calendar day and displaying that as text, because if the date in Col D is
the 15th or later and it happens to be in February of a non-leap year then
the result would be the 29th of February or later which wouldn't exist in
that year. By using the format Year("year of col d") Month("Month of col D")
and day("Day of Col D" + 14), Excel will fix the month and year to correspond
to this new date.

Otherwise if you have a date data type, you simply add 14 to it and store it
in the data object necessary for Column F of the same row.

Don't know if that helps, there are others that can provide you the straight
code, I tend to try to provide the thought process to construct the code,
because there are a number of ways to get to the same result.

"Jock" wrote:

When a date is placed in any cell D, I would like either:
1) a comment to automatically be accociated to cell F on the same row with a
date displayed which will be the date from D + 14, OR
2) When the cell in F has focus, the date (D + 14) appears in a pre
determined cell at the top of the page, F2 for instance.

Any ideas?
--
Traa Dy Liooar

Jock

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Dates and comments

Jock,

Try the worksheet change code below. This is very basic and you would need
to consider what you would do if the cell already had a comment. As a minimum
you should check to see if there is to prevent the code giving an error with

Set cmt = ActiveCell.Comment
If cmt Is Nothing Then
'insert your comment




Private Sub Worksheet_Change(ByVal Target As Range)
If Not IsDate(Target) Or Target.Cells.Count 1 Then Exit Sub
If Not Intersect(Target, Range("D:D")) Is Nothing Then
DateFormat = "dd-mmm-yy"
Newdate = DateAdd("D", 14, Target.Value)
Target.Offset(, 2).AddComment.Text Text:=Format(Newdate, DateFormat)
End If
End Sub

Mike

"Jock" wrote:

When a date is placed in any cell D, I would like either:
1) a comment to automatically be accociated to cell F on the same row with a
date displayed which will be the date from D + 14, OR
2) When the cell in F has focus, the date (D + 14) appears in a pre
determined cell at the top of the page, F2 for instance.

Any ideas?
--
Traa Dy Liooar

Jock

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Dates and comments

Hi,

And for option 2 try this. Once again consider some error trapping by
checking if there's a date in column D for example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("F:F")) Is Nothing Then
Range("F2") = DateAdd("D", 14, Target.Offset(, -2).Value)
End If
End Sub

Mike

"Jock" wrote:

When a date is placed in any cell D, I would like either:
1) a comment to automatically be accociated to cell F on the same row with a
date displayed which will be the date from D + 14, OR
2) When the cell in F has focus, the date (D + 14) appears in a pre
determined cell at the top of the page, F2 for instance.

Any ideas?
--
Traa Dy Liooar

Jock

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Dates and comments

I get the message "Invalid procedure call or argument" with this one,
referring to the line beginning 'Range("F2")=......
??
Traa Dy Liooar

Jock


"Mike H" wrote:

Hi,

And for option 2 try this. Once again consider some error trapping by
checking if there's a date in column D for example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("F:F")) Is Nothing Then
Range("F2") = DateAdd("D", 14, Target.Offset(, -2).Value)
End If
End Sub

Mike

"Jock" wrote:

When a date is placed in any cell D, I would like either:
1) a comment to automatically be accociated to cell F on the same row with a
date displayed which will be the date from D + 14, OR
2) When the cell in F has focus, the date (D + 14) appears in a pre
determined cell at the top of the page, F2 for instance.

Any ideas?
--
Traa Dy Liooar

Jock



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Dates and comments

Hi,

The only way I can make this error is with text in column D, did you put it
in as worksheet code and copy it exactly?

Mike

"Jock" wrote:

I get the message "Invalid procedure call or argument" with this one,
referring to the line beginning 'Range("F2")=......
??
Traa Dy Liooar

Jock


"Mike H" wrote:

Hi,

And for option 2 try this. Once again consider some error trapping by
checking if there's a date in column D for example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("F:F")) Is Nothing Then
Range("F2") = DateAdd("D", 14, Target.Offset(, -2).Value)
End If
End Sub

Mike

"Jock" wrote:

When a date is placed in any cell D, I would like either:
1) a comment to automatically be accociated to cell F on the same row with a
date displayed which will be the date from D + 14, OR
2) When the cell in F has focus, the date (D + 14) appears in a pre
determined cell at the top of the page, F2 for instance.

Any ideas?
--
Traa Dy Liooar

Jock

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Dates and comments

Last one for the day!
I'm keen to get this one to work so that when a date is entered in 'D', a
comment box appears in 'F' with 'D's date plus 14 in it.
This would save a lot of grief!
However, I can't get any comment box to appear with you code. I have copied
it into a Worksheet_Change event that is already so I'll copy the whole thing
below to see if you can help me out on this one.
Thanks Mike.

Private Sub Worksheet_Change(ByVal Target As Range)

'Enters todays date in A when case number entered in B
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B5:B100")) Is Nothing Then
With Target
If .Value < "" Then
.Offset(0, -1).Value = Format(Date, "dd/mmm")
End If
End With
End If
'Application.EnableEvents = True


'Application.EnableEvents = False
If Not IsDate(Target) Or Target.Cells.Count 1 Then Exit Sub
If Not Intersect(Target, Range("I:I")) Is Nothing Then
DateFormat = "dd-mmm"
Newdate = DateAdd("I", 14, Target.Value)
Target.Offset(, 1).AddComment.Text Text:=Format(Newdate, DateFormat)
Application.EnableEvents = True
End If
End Sub


--
Traa Dy Liooar

Jock


"Mike H" wrote:

Hi,

The only way I can make this error is with text in column D, did you put it
in as worksheet code and copy it exactly?

Mike

"Jock" wrote:

I get the message "Invalid procedure call or argument" with this one,
referring to the line beginning 'Range("F2")=......
??
Traa Dy Liooar

Jock


"Mike H" wrote:

Hi,

And for option 2 try this. Once again consider some error trapping by
checking if there's a date in column D for example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("F:F")) Is Nothing Then
Range("F2") = DateAdd("D", 14, Target.Offset(, -2).Value)
End If
End Sub

Mike

"Jock" wrote:

When a date is placed in any cell D, I would like either:
1) a comment to automatically be accociated to cell F on the same row with a
date displayed which will be the date from D + 14, OR
2) When the cell in F has focus, the date (D + 14) appears in a pre
determined cell at the top of the page, F2 for instance.

Any ideas?
--
Traa Dy Liooar

Jock

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Dates and comments

I have changed some of the columns btw :)
--
Traa Dy Liooar

Jock


"Jock" wrote:

Last one for the day!
I'm keen to get this one to work so that when a date is entered in 'D', a
comment box appears in 'F' with 'D's date plus 14 in it.
This would save a lot of grief!
However, I can't get any comment box to appear with you code. I have copied
it into a Worksheet_Change event that is already so I'll copy the whole thing
below to see if you can help me out on this one.
Thanks Mike.

Private Sub Worksheet_Change(ByVal Target As Range)

'Enters todays date in A when case number entered in B
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B5:B100")) Is Nothing Then
With Target
If .Value < "" Then
.Offset(0, -1).Value = Format(Date, "dd/mmm")
End If
End With
End If
'Application.EnableEvents = True


'Application.EnableEvents = False
If Not IsDate(Target) Or Target.Cells.Count 1 Then Exit Sub
If Not Intersect(Target, Range("I:I")) Is Nothing Then
DateFormat = "dd-mmm"
Newdate = DateAdd("I", 14, Target.Value)
Target.Offset(, 1).AddComment.Text Text:=Format(Newdate, DateFormat)
Application.EnableEvents = True
End If
End Sub


--
Traa Dy Liooar

Jock


"Mike H" wrote:

Hi,

The only way I can make this error is with text in column D, did you put it
in as worksheet code and copy it exactly?

Mike

"Jock" wrote:

I get the message "Invalid procedure call or argument" with this one,
referring to the line beginning 'Range("F2")=......
??
Traa Dy Liooar

Jock


"Mike H" wrote:

Hi,

And for option 2 try this. Once again consider some error trapping by
checking if there's a date in column D for example

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("F:F")) Is Nothing Then
Range("F2") = DateAdd("D", 14, Target.Offset(, -2).Value)
End If
End Sub

Mike

"Jock" wrote:

When a date is placed in any cell D, I would like either:
1) a comment to automatically be accociated to cell F on the same row with a
date displayed which will be the date from D + 14, OR
2) When the cell in F has focus, the date (D + 14) appears in a pre
determined cell at the top of the page, F2 for instance.

Any ideas?
--
Traa Dy Liooar

Jock

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking computer dates (time) to spreadsheet dates that have formu bigisle Excel Worksheet Functions 3 January 3rd 10 08:05 PM
excel 2000 how to format the comments font all comments Delquestion Excel Discussion (Misc queries) 1 October 8th 09 02:19 PM
match one column with dates to several colums with dates, copy pas Torben Excel Programming 4 November 3rd 08 04:10 PM
in excel useing comments how do you add clip art to comments? dhouse New Users to Excel 2 July 18th 07 08:14 AM
Toggle a range of Julian dates to Gregorian Dates and Back PSKelligan Excel Programming 4 May 8th 07 05:51 AM


All times are GMT +1. The time now is 05:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"