Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Automatically change cell comments

Hi,

I have a range of cells where the user will be able to select an option code
from a data validation list.

I would like to be able to automatically update cell comments to provide a
usefull description depending on which option code has been selected from the
validation list.

I have the following code which works for a single cell and updates the
referenced comment for that cell.

How can I change this so it will work for any cell within a specified range
and update the comment for that cell ?

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F2")) Is Nothing Then
If Target.Value = "RM4" Then
Comments(1).Text Target & " " & Sheet4.Range("C4")
ElseIf Target.Value = "RM5" Then
Comments(1).Text Target & " " & Sheet4.Range("C6")
ElseIf Target.Value = "" Then
Comments(1).Text "Selection Required"
End If
End If
end sub

thanks,
Marcus

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Automatically change cell comments

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("F2:F10")) Is Nothing Then
If Target.Value = "RM4" Then
Target.Comment.Text Target & " " & Sheet4.Range("C4")
ElseIf Target.Value = "RM5" Then
Target.Comment.Text Target & " " & Sheet4.Range("C6")
ElseIf Target.Value = "" Then
Target.Comment.Text "Selection Required"
End If
End If
End Sub

Works, but assumes the comment for the cell already exists.

--
Regards,
Tom Ogilvy


"Marcus B" wrote:

Hi,

I have a range of cells where the user will be able to select an option code
from a data validation list.

I would like to be able to automatically update cell comments to provide a
usefull description depending on which option code has been selected from the
validation list.

I have the following code which works for a single cell and updates the
referenced comment for that cell.

How can I change this so it will work for any cell within a specified range
and update the comment for that cell ?

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F2")) Is Nothing Then
If Target.Value = "RM4" Then
Comments(1).Text Target & " " & Sheet4.Range("C4")
ElseIf Target.Value = "RM5" Then
Comments(1).Text Target & " " & Sheet4.Range("C6")
ElseIf Target.Value = "" Then
Comments(1).Text "Selection Required"
End If
End If
end sub

thanks,
Marcus

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Automatically change cell comments

Worked a charm

thanks,
Marcus

"Tom Ogilvy" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("F2:F10")) Is Nothing Then
If Target.Value = "RM4" Then
Target.Comment.Text Target & " " & Sheet4.Range("C4")
ElseIf Target.Value = "RM5" Then
Target.Comment.Text Target & " " & Sheet4.Range("C6")
ElseIf Target.Value = "" Then
Target.Comment.Text "Selection Required"
End If
End If
End Sub

Works, but assumes the comment for the cell already exists.

--
Regards,
Tom Ogilvy


"Marcus B" wrote:

Hi,

I have a range of cells where the user will be able to select an option code
from a data validation list.

I would like to be able to automatically update cell comments to provide a
usefull description depending on which option code has been selected from the
validation list.

I have the following code which works for a single cell and updates the
referenced comment for that cell.

How can I change this so it will work for any cell within a specified range
and update the comment for that cell ?

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F2")) Is Nothing Then
If Target.Value = "RM4" Then
Comments(1).Text Target & " " & Sheet4.Range("C4")
ElseIf Target.Value = "RM5" Then
Comments(1).Text Target & " " & Sheet4.Range("C6")
ElseIf Target.Value = "" Then
Comments(1).Text "Selection Required"
End If
End If
end sub

thanks,
Marcus

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
Automatically change cell colors based on date in cell Greg Excel Discussion (Misc queries) 2 January 27th 09 05:55 PM
How to change shapes for Cell Comments Jan T.[_3_] Excel Discussion (Misc queries) 3 December 15th 08 11:10 PM
Automatically create comments based upon cell value and related datain database [email protected] Excel Discussion (Misc queries) 3 April 10th 08 12:31 PM
Can Comments be automatically converted to text cell values? tomdog61 Excel Discussion (Misc queries) 1 January 23rd 05 09:38 PM
change automatically a value when another cell value changes CC Excel Worksheet Functions 2 January 7th 05 02:12 PM


All times are GMT +1. The time now is 09:03 PM.

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"