![]() |
Data validation with the Select Case statement
Billabong
Try: Private Sub CommandButton1_Click() Select Case Cells(5, "F") '= "istext()" Case "trillium" Cells(2, "B") = "trillium" Cells(3, "B") = "456 maple rd." Case "brooks" Cells(2, "B") = "Brooks ltd" Cells(3, "B") = "123 maple rd." Case "peterson" Cells(2, "B") = "peterson ltd" Cells(3, "B") = "789 maple rd." Case Else Cells(2, "B") = "" Cells(3, "B") = "" End Select End Sub If you want to make sure there is something in F5 before you start, then perform the test and only move onto the Select statement if it is valid. eg If WorksheetFunction.IsText(Cells(5, "F")) Then ... Tony -----Original Message----- Hello Iam trying to use a drop down list created by data validation to generate an address. The user selects the name then presses command buton to make address appear. When I run the program below it does not select the correct address with respect to the name of company in drop down list. For example if I select Brooks in drop down list it displays trilliums address Can anyone figure this out- TIA Private Sub CommandButton1_Click() Select Case Cells(5, "F") = "istext()" Case Cells(5, "F") = "trillium" Cells(2, "B") = "trillium" Cells(3, "B") = "456 maple rd." Case Cells(5, "F") = "brooks" Cells(2, "B") = "Brooks ltd" Cells(3, "B") = "123 maple rd." Case Else Cells(5, "F") = "peterson" Cells(2, "B") = "peterson ltd" End Select End Sub . |
All times are GMT +1. The time now is 07:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com