While to create multiple dependency via macros, i am getting error on
Still trying to figure out how to pass range value into the formula section
So atlast i did manage to find a solution which is
But the Issue here is that should should have lists already in the area where the formula is going to be written but if you do it on a blank default cell, i get an error of
Runtime-Time error '1004':
Application-defined or object-defined error.... could anyone help me out with this.
Code:
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=indirect("A" & i)"
Code:
Sub listing()
Dim cellv As Range
For i = 3 To 10000
Set cella = Sheet1.Range("A" & i)
With cella.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=Main"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Invalid Input"
.InputMessage = ""
.ErrorMessage = "Select the location only from the dropdown list."
.ShowInput = False
.ShowError = True
End With
Set cellb = Sheet1.Range("B" & i)
With cellb.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=indirect("A" & i)"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Invalid Input"
.InputMessage = ""
.ErrorMessage = "Select the location only from the dropdown list."
.ShowInput = False
.ShowError = True
End With
Next
End Sub
So atlast i did manage to find a solution which is
Code:
Sub listing()
Dim cellv As Range
For i = 3 To 10
Set cellb = Sheet1.Range("A" & i)
With cellb.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=Main"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Invalid Input"
.InputMessage = ""
.ErrorMessage = "Select the location only from the dropdown list."
.ShowInput = False
.ShowError = True
End With
Set cellb = Sheet1.Range("B" & i)
With cellb.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=INDIRECT(OFFSET($A$" & i & ",0,0))"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Invalid Input"
.InputMessage = ""
.ErrorMessage = "Select the location only from the dropdown list."
.ShowInput = False
.ShowError = True
End With
Next
End Sub
But the Issue here is that should should have lists already in the area where the formula is going to be written but if you do it on a blank default cell, i get an error of
Runtime-Time error '1004':
Application-defined or object-defined error.... could anyone help me out with this.