ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel2000: How to copy data validation using VBA (https://www.excelbanter.com/excel-programming/303892-excel2000-how-copy-data-validation-using-vba.html)

Arvi Laanemets

Excel2000: How to copy data validation using VBA
 
Hi

How doesn't the code from below work? I get Run-time error '1004':
PasteSpecial method of Range class failed!

....
Sheets("SheetName").Range("A1:D1").Offset(RowNo - 2, 0).Copy
Sheets("SheetName").Range("A1:D1").Offset(RowNo - 1, 0).PasteSpecial _
Paste:=xlDataValidation, Operation:=xlNone, SkipBlanks:=False,
Transpose:=False
....

It does work with xlPasteFormats
Sheets("SheetName").Range("A1:D1").Offset(RowNo - 1, 0).PasteSpecial _
Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False,
Transpose:=False

I'm writing an Open event for workbook, which when needed adds new records
into table, and copies some data valdation lists from existing rows into new
ones.


Thanks in advance for any help

--
Arvi Laanemets
(When sending e-mail, use address arvil<Attarkon.ee)



Arvi Laanemets

Excel2000: How to copy data validation using VBA
 
Solved (found a hint from web)!


Sheets("SheetName").Range("A1:D1").Offset(RowNo - 1, 0).PasteSpecial _
Paste:=xlDataValidation, Operation:=xlNone, SkipBlanks:=False,
Transpose:=False



Sheets("SheetName").Range("A1:D1").Offset(RowNo - 1, 0).PasteSpecial _
Paste:=6, Operation:=xlNone, SkipBlanks:=False, Transpose:=False



--
Arvi Laanemets
(When sending e-mail, use address arvil<Attarkon.ee)




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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com