I have a sheet in a workbook that contains a list of categories for recipes (like chicken,beef,italian,mexican,chinese,american,etc...).
In that same sheet there is a list for each of the items in the categories list. These lists contain references to recipes that fit under that specific category.
These named lists are dynamic as values (recipes and categories) can be added to or taken away from them based on text files that are used to update (add to) the sheet.
Another sheet references this named "categories" list via data validation.
Depending what category is selected in this first data validation cell, I have a second data validation cell that references the list for the selected category.
The code I have works for this so far (it's pretty simple due to the named range naming convention I used) but would like the value in the cell to default to the first item (recipe) in that category.
Here's the code that works:
I've tried adding the following just before the 'End Sub' line but none work.
Can someone tell me how to reference the first cell in a named range?
Edit: I've also now tried this, but it still doesn't work:
In that same sheet there is a list for each of the items in the categories list. These lists contain references to recipes that fit under that specific category.
These named lists are dynamic as values (recipes and categories) can be added to or taken away from them based on text files that are used to update (add to) the sheet.
Another sheet references this named "categories" list via data validation.
Depending what category is selected in this first data validation cell, I have a second data validation cell that references the list for the selected category.
The code I have works for this so far (it's pretty simple due to the named range naming convention I used) but would like the value in the cell to default to the first item (recipe) in that category.
Here's the code that works:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim list As String
Dim lname As String
'Get the name of the range that the
'data validation cell is to refer to
lname = "Type" & Range("C2").Value & "List"
list = "=" & lname
'MsgBox (list)
Range("C3").Validation.Delete
Range("C3").Validation.Add _
Type:=xlValidateList, _
Formula1:=list
End Sub
Can someone tell me how to reference the first cell in a named range?
Code:
Range("C4").Value = Range(lname).Value
Range("C4").Value = Index(lname, 1, 1)
Range("C4").Value = Index(lname, 1)
Range("C4").Value = Range(lname)(1).Value
Range("C4").Value = Range(lname)(1, 1).Value
Edit: I've also now tried this, but it still doesn't work:
Code:
Range("C4").Value = Range(lname).Cells(1).Value
Last edited: