john taiariol explained on 4/8/2011 :
On Apr 8, 1:07*am, GS wrote:
john taiariol has brought this to us :
so if I have column heading called "Name" how would you write the code?
What code are you refering to? If you mean how would I use "Name" in
code it would be same as I demonstrated with the column heading
"Field1". Though, I'd be a bit more descriptive using "Name". For
example, if it was the heading for a list of items where each item had
a name I'd use "ItemName" for the range name.
If you mean how do you name a range, use the namebox on the left side
of the Formula Bar. Make sure, though, that you give it local (sheet
level) scope. Here's how:
* Select the column to be named.
* Click in the namebox and type *'<Sheet name'!ItemName
* ..where <Sheet name is the name of the active worksheet.
* Press Enter.
Now, whenever your code refs Range("ItemName") it will refer to that
column. If you ref this column in formulas on another worksheet then
include the sheetname.
* Example: *=SUMIF(Sheet1!ItemName,"TOOL ASSEMBLY", [SumRange])
If you refer to it in code then specify the worksheet as follows:
* Sheets("Sheet1").Range("ItemName")
--
Garry
Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc
I tried to put it in here and it didnt' work??
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col F
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 6 Then
n = Target.Row
If Excel.Range("F" & n).Value = "TOOL ASSEMBLY" Then
Excel.Range("G" & n).Value = "A, B, C, D or whatever"
End If
End If
enditall:
Application.EnableEvents = True
End Sub
You tried to put what in here? I don't see anything I was talking about
in this code sample!
Since the cell you're checking IS 'Target' then why are you refering to
it as Range("F" & n)? I revised your code as follows and tested it.
Works fine for me!
<aircode
'Column 'F' is named "ItemName"
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("ItemName")) Is Nothing Then
If Target.Value = "TOOL ASSEMBLY" Then _
Target.Offset(, 1) = "A, B, C, D or whatever"
End If
End Sub
</aircode
--
Garry
Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc