Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Error 1004 when using VBA to set Validation from list on another s

Hi,
I get Error 1004 when I use the following code to set Validation using a
list on another sheet.

Lookup List Name: ProductTypes
Range to apply Validation to: rngValidate2

The list is on another page but the help seems to indicate all you have to
do is put the range name in the formula without the sheet name.

Thanks,
MikeZz

Sub Test_Add_Validation()
Dim rngValidate2 As Range

Set rngValidate2 = Selection
Call A91_Set_Basic_Validation(rngValidate2, "=ProductTypes")

End Sub

Private Sub A91_Set_Basic_Validation(rng As Range, lookupFormula)

With rng.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:=lookupFormula
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Error 1004 when using VBA to set Validation from list on another s

Mike,

It should work, check for a typo in the Lookup List Name.

Regards,
Per

"MikeZz" skrev i meddelelsen
...
Hi,
I get Error 1004 when I use the following code to set Validation using a
list on another sheet.

Lookup List Name: ProductTypes
Range to apply Validation to: rngValidate2

The list is on another page but the help seems to indicate all you have to
do is put the range name in the formula without the sheet name.

Thanks,
MikeZz

Sub Test_Add_Validation()
Dim rngValidate2 As Range

Set rngValidate2 = Selection
Call A91_Set_Basic_Validation(rngValidate2, "=ProductTypes")

End Sub

Private Sub A91_Set_Basic_Validation(rng As Range, lookupFormula)

With rng.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:=lookupFormula
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime-error 1004 (excel 2007) when selecting validation list optiontriggering worksheet_change property Erik[_11_] Excel Programming 1 April 2nd 09 06:30 PM
data Validation Dependent List Error Marilyn Excel Discussion (Misc queries) 2 February 5th 08 06:05 PM
1004 Cell Protected Error for data validation lists when locked and protected [email protected] Excel Programming 2 November 7th 06 10:07 AM
Error 1004 with Data Validation in VBA [email protected] Excel Programming 0 December 27th 04 08:05 PM
Sorting a 2 column list with VBA using Worksheet change produces 1004 error Casey[_10_] Excel Programming 3 June 28th 04 04:38 PM


All times are GMT +1. The time now is 03:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"