Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a named range in sheet2 called "Locations"
In sheet 1 i use a validation dropdown list on required cells to list the Location values. I am trying to identify IF the value chosen was a particular item from the "Locations" list. "Locations" = Sheet2 A1-A12 I selected the first value in the list in the Validation List in Sheet1 (which is actally Sheet2 A1) How can i capture the correct cell value chosen? If Range("C5").Value = Locations(Cells(1)) Then ' <=== ??? 'do stuff here end if Corey.... |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If Not IsError(Application.Match(Range("C5").Value, Range("Locations"),0))
Then MsgBox Application.Match)Range("C5").Value, Range("Locations"),0) ' the index within Locations End If -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Corey ...." wrote in message ... I have a named range in sheet2 called "Locations" In sheet 1 i use a validation dropdown list on required cells to list the Location values. I am trying to identify IF the value chosen was a particular item from the "Locations" list. "Locations" = Sheet2 A1-A12 I selected the first value in the list in the Validation List in Sheet1 (which is actally Sheet2 A1) How can i capture the correct cell value chosen? If Range("C5").Value = Locations(Cells(1)) Then ' <=== ??? 'do stuff here end if Corey.... |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm not 100% sure what you are actually looking for, so here is a shot-gun
type of an answer hoping that one of these is what you want. So, if you are just looking to see if the value in C5 is in the list somewhere, you could do this... If Not Range("Locations").Find(Range("C5").Value) Is Nothing Then ' C5 was in the list, so do your stuff here End If Now, although I left them out for this example, it would be a good idea to include the references to the worksheet for each of the ranges (which is necessary to do if they reside on different worksheets). If, instead, you want to know if it matches a particular item in the list, I would think you could test for that directly (using the contents of the cell you are interested in match as opposed to a functional reference to the content). Assuming you are looking specific match a particular index value, you can get that index value within the list using this... MatchedIndexValue = Range("Locations").Find(Range("C5").Value).Row - Range("Locations").Row + 1 And, again, it would be a good idea to reference the worksheet for each of the ranges. If, instead of the index location within the list itself, you just want the row the match occurred on, then you would use this... RowMatchWasOn = Range("Locations").Find(Range("C5").Value).Row One last thing to note... since your list started on Row 1, the values in MatchedIndexValue and RowMatchWasOn are identical (this will only happen when the list starts on Row 1). Rick "Corey ...." wrote in message ... I have a named range in sheet2 called "Locations" In sheet 1 i use a validation dropdown list on required cells to list the Location values. I am trying to identify IF the value chosen was a particular item from the "Locations" list. "Locations" = Sheet2 A1-A12 I selected the first value in the list in the Validation List in Sheet1 (which is actally Sheet2 A1) How can i capture the correct cell value chosen? If Range("C5").Value = Locations(Cells(1)) Then ' <=== ??? 'do stuff here end if Corey.... |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Change:
If Range("C5").Value = Locations(Cells(1)) Then ' <=== ??? 'do stuff here end if TO: If Range("C5").Value = Range("Locations")(1) Then 'do stuff here end if This will check to see if Sheet1.Range("C5") matches the first item in your Locations list. If it matches, your 'do stuff' will execute. "Corey ...." wrote: I have a named range in sheet2 called "Locations" In sheet 1 i use a validation dropdown list on required cells to list the Location values. I am trying to identify IF the value chosen was a particular item from the "Locations" list. "Locations" = Sheet2 A1-A12 I selected the first value in the list in the Validation List in Sheet1 (which is actally Sheet2 A1) How can i capture the correct cell value chosen? If Range("C5").Value = Locations(Cells(1)) Then ' <=== ??? 'do stuff here end if Corey.... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can you name a worksheet by refering to a cell reference or range | Excel Discussion (Misc queries) | |||
Refering to a named range in a chart: 2007 | Excel Worksheet Functions | |||
refering to a named range on a different worksheet | Excel Programming | |||
inserting a named range into new cells based on a named cell | Excel Discussion (Misc queries) | |||
help in refering to a range named in a cell | Excel Programming |