Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PasteSpecial "Paste:=xlDataValidation" Not Valid? 1

Status
Not open for further replies.

origapizni

Programmer
Aug 2, 2001
29
0
0
US
I recorded this but when I play it back, it fails with
Runtime error '1004': 'PasteSpecial method of Range class failed'. I can't locate the xlDataValidation constant in my Object Browser, but all the other "Paste:=" constants show up. Is this a known bug in Excel? Any ideas? Anyone else experienced this?

Sub Macro4()
Rows("28:28").Select
Selection.Copy
Rows("27:27").Select
Selection.PasteSpecial Paste:=xlDataValidation, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

Using Office 2k, Excel 2k, Win 2k

Thanks in advance!
 
I get the same result. Very strange. It can be recorded but is invalid in playback. Using Excel 2K on Win 98.

At least xlPasteAll works and does past the validation(s). I guess you have a choice: Paste all and undo what needs to be undone or set up the validations after pasting.

Maybe someone else here can find a way.
 
I had this crop up a little while ago - it was an error in xl97 but seems like it's not been sorted yet.
When you use PasteSpecial Validation in 97, what is recorded is xlAllExceptBorders

What you can do is just use the constant that the xl..... refers to which, in this case, I believe is 6
So your code would be

.pastespecial Paste:=6

rather than
.pastespecial Paste:=xlDataValidation

HTH Rgds
Geoff

Si hoc legere scis, nimis eruditionis habes
 
This bug was fixed in excel XP. The value of this constant is still 6, name: xlPasteValidation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top