J
Joe Fawcett
I'm trying to add a dropdown list dynamically and for Excel 2000 and above
the following sub works fine:
Public Sub AddDropdown(ByRef ToCell As Range, ByRef RefCell As Range)
Dim oValidation As Validation
Set oValidation = RefCell.Validation
ToCell.Validation.Delete
ToCell.Validation.Add oValidation.Type, oValidation.AlertStyle,
oValidation.Operator, oValidation.Formula1
ToCell.Validation.ErrorTitle = oValidation.ErrorTitle
ToCell.Validation.ErrorMessage = oValidation.ErrorMessage
End Sub
I give it a reference cell that has validation set as required and a target
cell and copy the properties. However it fails in Excel 97 because the
AlertStyle always returns -1. Now I could hard code the value 1 instead but
I'd like to get to the bottom of this if possible.
Thanks
Joe (MVP)
the following sub works fine:
Public Sub AddDropdown(ByRef ToCell As Range, ByRef RefCell As Range)
Dim oValidation As Validation
Set oValidation = RefCell.Validation
ToCell.Validation.Delete
ToCell.Validation.Add oValidation.Type, oValidation.AlertStyle,
oValidation.Operator, oValidation.Formula1
ToCell.Validation.ErrorTitle = oValidation.ErrorTitle
ToCell.Validation.ErrorMessage = oValidation.ErrorMessage
End Sub
I give it a reference cell that has validation set as required and a target
cell and copy the properties. However it fails in Excel 97 because the
AlertStyle always returns -1. Now I could hard code the value 1 instead but
I'd like to get to the bottom of this if possible.
Thanks
Joe (MVP)