Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using VBA to set Excel Data Validation

Hey there,

I currently use a 'two-tier' data validation rule. the first being:
Data¦Validation¦List
Source:
=List1 'this has 4 arguments

The second list is fed from this List1 as:
=CHOOSE(VLOOKUP(E4,List1_Elements,2,FALSE),List2a, List2b,List2c,List2d)

When applying the second validation, Excel naturally gives an eror:
'The source currently equates to an error. Do you wish to continue?'
I press 'Yes' and the process works....

I need to recreate this setup process in VBA. However, when I get to the
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:= _

"=CHOOSE(VLOOKUP(E4,List1_Elements,2,FALSE),List2a ,List2b,List2c,List2d)"

VBA crashes as it cannot handle the Excel error....

How do i get around this?!?

thx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Using VBA to set Excel Data Validation

Hi
Try

Dim response as Variant
err.clear
On Error Resume Next
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:= _

"=CHOOSE(VLOOKUP(E4,List1_Elements,2,FALSE),List2a ,List2b,List2c,List2d)"
If err.number<0 then
Response = Msgbox("The source currently equates to an error." & vbcr
_
& "Do you wish to continue?", vbYesNo, "Error Message")
If Response = vbYes then
'some code
Else
'some other code
end if
end if
On error Goto 0

regards
Paul

KurviousKoala wrote:
Hey there,

I currently use a 'two-tier' data validation rule. the first being:
Data¦Validation¦List
Source:
=List1 'this has 4 arguments

The second list is fed from this List1 as:
=CHOOSE(VLOOKUP(E4,List1_Elements,2,FALSE),List2a, List2b,List2c,List2d)

When applying the second validation, Excel naturally gives an eror:
'The source currently equates to an error. Do you wish to continue?'
I press 'Yes' and the process works....

I need to recreate this setup process in VBA. However, when I get to the
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:= _

"=CHOOSE(VLOOKUP(E4,List1_Elements,2,FALSE),List2a ,List2b,List2c,List2d)"

VBA crashes as it cannot handle the Excel error....

How do i get around this?!?

thx


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
custom data validation on cells with data validation values AKrobbins Excel Worksheet Functions 2 June 21st 11 04:20 PM
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
Data validation causing problems when using a data form in Excel 2 Peter Excel Worksheet Functions 1 November 27th 09 12:00 AM
data validation invalid in dynamic validation list ilia Excel Worksheet Functions 0 November 7th 06 12:54 PM
Data validation with validation lists and combo boxs Keith Excel Discussion (Misc queries) 1 October 12th 06 11:08 AM


All times are GMT +1. The time now is 06:49 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"