LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default Adding Validation When Source Validates To Error?

When I add validation to a cell manually - using Excel's UI -
Excel issues a "The Source currently evaluates to an error. Do
you wish to continue dialog". I click "Yes" and all is well.

But when I try to add that same validation via VBA code from an
MS Access app, it traps out with "1004: Application-defined or
object-defined error"

It's the second validation in the code below. No problem
with the first one.

I'm assuming it's the "...source currently evaluates to an
error..." thing that's provoking the 1004.

If that's correct, is there a way around it?

Maybe something like an Excel equivalent of
DoCmd.SetWarnings=False that can be issued against the
Excel.Application object?

VBA Code:
================================================== ======== '
---------------------------------------------------
' Set up validation

2450 With myWS
2460 Set myRange = Range(.Cells(1, 1), .Cells(6, 1))
2461 With myRange.Validation
2462 .Delete
2463 .Add Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Operator:=xlBetween,
Formula1:="=DealNames" <===this one works, no problem
2464 .IgnoreBlank = True
2465 .InCellDropdown = True
2469 End With

2470 Set myRange = Range(.Cells(1, 2), .Cells(6, 2))
2471 With myRange.Validation
2472 .Delete
2473 .Add Type:=xlValidateList,
AlertStyle:=xlValidAlertStop, Operator:=xlBetween,
Formula1:="=INDIRECT(RC[-1])" '<==this one traps out w/1004
2474 .IgnoreBlank = True
2475 .InCellDropdown = True
2479 End With
2499 End With
================================================== ========
--
PeteCresswell
 
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 source = destination? andy62 Excel Worksheet Functions 7 December 4th 07 11:10 PM
How can I set up a validation list and source to another workshee Julie Harvell Excel Worksheet Functions 1 November 8th 07 08:51 PM
Validation source field size and function. Dudedad Excel Discussion (Misc queries) 1 June 20th 07 07:47 PM
Validation source field size and function. Dudedad Excel Worksheet Functions 1 June 20th 07 06:54 PM
Data Validation Source Box Drahos Excel Worksheet Functions 3 December 8th 05 11:21 AM


All times are GMT +1. The time now is 08:28 AM.

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"