Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 30th, 2008, 03:41 AM
Registered User
 
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default cells values with validation in another cell

How to set a validation in a cell and create a sublist based on the value of the current cell.

Example: cell A1 has a list of validations like "a","b","c" and when "a" is selected from the drop down menu it should set the validation in cell B1 like "apple","ball","cat". if "b" is chosed in cell A1, it should display validation list of "b", like "ant","bat","cat" and like the same for "c".

Thanks,
Rahuf
 
Old May 30th, 2008, 04:05 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Rahuf

You can try using the Worksheet_Change event for that particuar sheet

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
       Select Case Target.Value
        Case "A"
            Range("B1").Validation.Delete
            Range("B1").Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, Operator:=xlBetween, Formula1:="cat,dog,ball"
        Case "B"
            Range("B1").Validation.Delete
            Range("B1").Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, Operator:=xlBetween, Formula1:="apple,baloon,car"
        Case Else
            Range("B1").Validation.Delete
            Range("B1").Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertInformation, Operator:=xlBetween, Formula1:="Else1,Else2,Else3"
       End Select
    End If
End Sub
Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
In-Cell Drop Down Via Data Validation Coby Excel VBA 1 October 16th, 2007 04:13 PM
HOW CHAGE VALUES IN CELLS DYNAMICALLY dATAGRIDVIEW hyder_master C# 2005 1 October 9th, 2007 04:13 AM
datagridview cell validation kscase Pro Visual Basic 2005 1 July 12th, 2007 07:21 AM
how to add from text values into excel cells kotaiah Excel VBA 2 September 12th, 2006 10:55 AM
validation of one cell of a Data Grid to another Ljhopkins ASP.NET 1.0 and 1.1 Basics 1 November 5th, 2005 01:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.