Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Irregular VBA error with data validation

I'm running the following code to add a data validation list (dynamic range)
to a cell. About 30% of the time it spits out an Error 1004 but the rest of
the time it works. I dont do anything differently between the runs

Any ideas?


With Range("D7").Validation
.Delete
.Add Type:=xlValidateList, Formula1:="=val1"
.IgnoreBlank = True
.InCellDropdown = True
End With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Irregular VBA error with data validation

i'm quite sure it must have to do with the "existence"
or validity of the named range (or formula) val.

if that's a relative referenced formula it may throw
an error if called from d7

Sub ValidValidation()
With Range("d7")
.Activate
If IsError(Evaluate("val")) Then
MsgBox "Ouch.. invalid Ref"
Else
With .Validation
.Delete
.Add Type:=xlValidateList, Formula1:="=val"
.IgnoreBlank = True
.InCellDropdown = True
End With
End If
End With
End Sub




keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Dave" wrote:

I'm running the following code to add a data validation list (dynamic
range) to a cell. About 30% of the time it spits out an Error 1004 but
the rest of the time it works. I dont do anything differently between
the runs

Any ideas?


With Range("D7").Validation
.Delete
.Add Type:=xlValidateList, Formula1:="=val1"
.IgnoreBlank = True
.InCellDropdown = True
End With




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Irregular VBA error with data validation

Thanks for the reply

The cell in question was merged - I think the error is gone now that it is
demerged.

"keepitcool" wrote in message
...
i'm quite sure it must have to do with the "existence"
or validity of the named range (or formula) val.

if that's a relative referenced formula it may throw
an error if called from d7

Sub ValidValidation()
With Range("d7")
.Activate
If IsError(Evaluate("val")) Then
MsgBox "Ouch.. invalid Ref"
Else
With .Validation
.Delete
.Add Type:=xlValidateList, Formula1:="=val"
.IgnoreBlank = True
.InCellDropdown = True
End With
End If
End With
End Sub




keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Dave" wrote:

I'm running the following code to add a data validation list (dynamic
range) to a cell. About 30% of the time it spits out an Error 1004 but
the rest of the time it works. I dont do anything differently between
the runs

Any ideas?


With Range("D7").Validation
.Delete
.Add Type:=xlValidateList, Formula1:="=val1"
.IgnoreBlank = True
.InCellDropdown = True
End With






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
Data Validation Error CH Excel Discussion (Misc queries) 1 January 26th 10 07:59 PM
Data Validation error Kristen Excel Discussion (Misc queries) 2 February 7th 08 02:36 PM
Data Validation error ?? Anthony Excel Worksheet Functions 1 February 10th 05 03:52 PM
Data Validation Error! keepitcool Excel Programming 2 August 19th 03 12:23 PM
Data Validation Error! Soniya Excel Programming 0 August 19th 03 08:31 AM


All times are GMT +1. The time now is 02:33 PM.

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

About Us

"It's about Microsoft Excel"