ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to copy Validation? (https://www.excelbanter.com/excel-programming/325037-how-copy-validation.html)

Joe HM

How to copy Validation?
 
Hello -

I need to copy the validation from one cell to the other. Recording a
macro gives me the following code:
Range("A1").Select
Selection.Copy
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValidation, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

What I was wondering if there is a way to do this without having to go
through the whole .Select. I do this a few times when a button is
pushed and I don't want to confuse the user by having a moving
selection. I also tried to do a
Range("A2").Validation = Range("A1").Validation
but that wouldn't work.

Any idea? Thanks!
Joe


Bernie Deitrick

How to copy Validation?
 
Joe,

Sorry if this is a late entry, but my OE shows this as not having been
answered:

Range("A1").Copy
Range("A2").PasteSpecial Paste:=xlPasteValidation
Application.CutCopyMode = False

HTH,
Bernie
MS Excel MVP


"Joe HM" wrote in message
oups.com...
Hello -

I need to copy the validation from one cell to the other. Recording a
macro gives me the following code:
Range("A1").Select
Selection.Copy
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValidation, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

What I was wondering if there is a way to do this without having to go
through the whole .Select. I do this a few times when a button is
pushed and I don't want to confuse the user by having a moving
selection. I also tried to do a
Range("A2").Validation = Range("A1").Validation
but that wouldn't work.

Any idea? Thanks!
Joe




Joe HM

How to copy Validation?
 
Bernie -

Thanks so much for your reply ... it was not late and very helpful.
Gush ... I could have thought of that myself!

Thanks again,
Joe


hr

How to copy Validation?
 
I tried copying a cell with validation in xl2000 to a new cell and it works
fine. Yet when I write a macro doing the same thing I get an error. If I
repeat the process using Excel2002 no problems. This is driving me crazy.
Any suggestions?
--
Thanks,
HR


"Joe HM" wrote:

Bernie -

Thanks so much for your reply ... it was not late and very helpful.
Gush ... I could have thought of that myself!

Thanks again,
Joe



Debra Dalgleish

How to copy Validation?
 
In the code, change:

Paste:=xlDataValidation

to:

Paste:=6

HR wrote:
I tried copying a cell with validation in xl2000 to a new cell and it works
fine. Yet when I write a macro doing the same thing I get an error. If I
repeat the process using Excel2002 no problems. This is driving me crazy.
Any suggestions?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


hr

How to copy Validation?
 
I made the changes to the program and it worked like a champ. I am rolling
out a spreadsheet to 100 salespeople that use EXCEL 2000 and now the
spreadsheet works. I had previously rolled out the spreadsheet and had major
problems since I had written the macro to work on Excel 2002 (where is
works). Thanks again your a life savor.
--
Thanks,
HR


"Debra Dalgleish" wrote:

In the code, change:

Paste:=xlDataValidation

to:

Paste:=6

HR wrote:
I tried copying a cell with validation in xl2000 to a new cell and it works
fine. Yet when I write a macro doing the same thing I get an error. If I
repeat the process using Excel2002 no problems. This is driving me crazy.
Any suggestions?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



Debra Dalgleish

How to copy Validation?
 
You're welcome. Thanks for letting me know that it worked for you.

HR wrote:
I made the changes to the program and it worked like a champ. I am rolling
out a spreadsheet to 100 salespeople that use EXCEL 2000 and now the
spreadsheet works. I had previously rolled out the spreadsheet and had major
problems since I had written the macro to work on Excel 2002 (where is
works). Thanks again your a life savor.



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 04:11 PM.

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