View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
mtm4300 via OfficeKB.com mtm4300 via OfficeKB.com is offline
external usenet poster
 
Posts: 43
Default Combo Box to Combo Box Selections

I am a beginner with VBA so I dont quite understand everything you wrote. I
dont know what to change and what to keep. Also the statement.

Range("c" & intRowNum).Validation.Add Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Operator:=xlBetween,
Formula1:="=RangeGetIt2"

appears in red. Do I need to change the format of it?

BadgerMK wrote:
Need to do this is 2 stages

firstly the following code will run each time value in combo1 is
changed, and needs to go in the Worksheet_Change(ByVal Target As
Range)

intRowNum = ActiveCell.Row
strAddress = Target.Address
If Left(strAddress, 3) = "$B$" Then
UpdateDropDown
Else
Exit Sub
End If

Secondly this will run the UpdateDropDown function which changes the
source values of Cmb2 depending on value selected in cmb1, each cmb1
value should have a matching cmb2 list, I use range names for each
list

UpdateDropDown function has this code as it's core

Case "CAPITAL"
Range("c" & intRowNum).Validation.Delete
Range("c" & intRowNum).Validation.Add Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Operator:=xlBetween,
Formula1:="=RangeGetIt2"
Range("c" & intRowNum).Validation.IgnoreBlank = True
Range("c" & intRowNum).Validation.InCellDropdown = True
Range("c" & intRowNum).Validation.ShowInput = True
Range("c" & intRowNum).Validation.ShowError = True
Case "INCOME"
Range("c" & intRowNum).Validation.Delete
Range("c" & intRowNum).Validation.Add Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Operator:=xlBetween,
Formula1:="=RangeGetIt3"
Range("c" & intRowNum).Validation.IgnoreBlank = True
Range("c" & intRowNum).Validation.InCellDropdown = True
Range("c" & intRowNum).Validation.ShowInput = True
Range("c" & intRowNum).Validation.ShowError = True
Case Else
Range("c" & intRowNum).Validation.Delete
Range("c" & intRowNum).Validation.Add Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Operator:=xlBetween,
Formula1:="=RangeGetIt"
Range("c" & intRowNum).Validation.IgnoreBlank = True
Range("c" & intRowNum).Validation.InCellDropdown = True
Range("c" & intRowNum).Validation.ShowInput = True
Range("c" & intRowNum).Validation.ShowError = True
End Select


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200602/1