Computer Learning Zone CLZ Access Excel Word Windows

Always get somebody else to do the lifting.

-287th Rule of Acquisition
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Forums > Excel
Back to Excel Forum    Comments List
Range Method limit Upload Images   Link   Email  
Gary 
Alex,
I actually found a work around so I thought Id post what was going on incase anyone else runs into this problem.

I have a fairly large spreadsheet that has a bunch of validation dropdowns. Now whenever a new sheet is needed I use a macro to create the new sheet and apply all the validations.

Original Code shortened

    With Range("B13:B20,B22:B29,B31:B42,B44:").Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=Keys!$C$2:$C$31"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True  
    End With

As my spreadsheet grew this worked fine until I figured out that the range method has a 255 character limit. Now it took me a bit to figure this out, but to get around the 255 character limit you have to use a union to join your string into a variable then use the properties of the variable to apply the validations.

New Code Shortened
Set R1 = Range("E13:AJ20,E22:AJ29,")
Set R2 = Range("E160:AJ171,E176:AJ183")

Set RngAll = Application.Union(R1, R2)
  
    'Key Range
    With RngAll.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=Keys!$A$2:$A$20"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True    
    End With





Reply from Alex Hedley:

Thanks for sharing.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Excel Forum.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/28/2024 7:16:43 AM. PLT: 0s