AusSteelMan
Board Regular
- Joined
- Sep 4, 2009
- Messages
- 208
Hi all,
I need to set a name to a range (Col T in sheet1) so I can use it in an Intersect statement.
I am sure it is an easy fix but I can't see it.
Extracts from my (latest attempt) code:
I have tried several things, but feel like I am guessing now.
This question is further to my previous question:
http://www.mrexcel.com/forum/showthread.php?t=422319
I started a new thread since 17 pages of new threads were posted in about 13 hours!!! Sorry if this was the wrong thing to do. But at least this post has a new set of tags...
Here is all the code in case it helps
Notes:
1. Sheet1 is actually called "MAE14-COG Release"
2. In the main body of code that adds comments to cells from a lookup table, "SelectedCell" used to say "T2" and the code worked perfectly when using cell T2. I am trying to expand to any cell in Col T
I am trying to make it so the code only applies to cells changed in column T. As shown in the previous post, I got the code to work for all of Col T, but it meant that the whole sheet would react to the code - bad result.
Regards,
Darren
I need to set a name to a range (Col T in sheet1) so I can use it in an Intersect statement.
I am sure it is an easy fix but I can't see it.
Extracts from my (latest attempt) code:
Code:
Dim FailureGroupCodes As Range
FailureGroupCodes = Sheets("Sheet1").Range("T:T")
I have tried several things, but feel like I am guessing now.
This question is further to my previous question:
http://www.mrexcel.com/forum/showthread.php?t=422319
I started a new thread since 17 pages of new threads were posted in about 13 hours!!! Sorry if this was the wrong thing to do. But at least this post has a new set of tags...
Here is all the code in case it helps
Notes:
1. Sheet1 is actually called "MAE14-COG Release"
2. In the main body of code that adds comments to cells from a lookup table, "SelectedCell" used to say "T2" and the code worked perfectly when using cell T2. I am trying to expand to any cell in Col T
Code:
Private Sub worksheet_change(ByVal Target As Range)
Dim x As String
Dim y As Long
Dim FailureGroupCodes As Range
Dim SelectedCell As String
FailureGroupCodes = Sheets("MAE14-COG Release").Range("T:T")
SelectedCell = ActiveCell.Address
If Not Intersect(Range("SelectedCell"), Range("FailureGroupCodes")) Is Nothing Then Exit Sub
If Not Intersect(Target, Range("SelectedCell")) Is Nothing Then
y = Sheets("LookupData").Range("B65536").End(xlUp).Row
Range("SelectedCell").ClearComments
Range("SelectedCell").AddComment.Visible = False
x = Application.WorksheetFunction.VLookup(Cells("SelectedCell"), Sheets("LookupData").Range("A2:B" & y), 2, False)
Range("SelectedCell").Comment.Text Text:=x
Range("SelectedCell").Comment.Shape.TextFrame.Characters.Font.Size = 12
Range("SelectedCell").Comment.Shape.TextFrame.AutoSize = True
MsgBox "Updated"
End If
'End If
End Sub
I am trying to make it so the code only applies to cells changed in column T. As shown in the previous post, I got the code to work for all of Col T, but it meant that the whole sheet would react to the code - bad result.
Regards,
Darren