Creating a Validation List Through Macro

P

pavankks

Hi,

I have two excel sheets
1) Excel1.xls which contains the code below. This excel sheet is use
to open Excel2.xls within which the validation list needs to b
created. But i seem to be having a problem here

I am trying to create a validation list through a macro. The code i a
using
is as follows:

'Open the excel sheet where the valdiation list is to be added
Set objExcel = CreateObject("Excel.Application")
ExcelToBeOpened = Application.GetOpenFilename(filefilter:="Excel Files

*.xls")
objExcel.Workbooks.Open Filename:=ExcelToBeOpened
objExcel.Visible = True

'The validation list is to be created in another excel sheet that i
open
Wit
objExcel.Workbooks(1).Worksheets("Sheet1").Range("N3:N1000").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, Formula1:="Yes,No"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

But this doesnt seem to work. Any ideas why and what change should b
done?

Thanks
--
Senior Consultant
Kanbay Software (I) Pvt. Ltd.
http://www.kanbay.com

Attachment filename: desktop.zip
Download attachment: http://www.excelforum.com/attachment.php?postid=64557
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top