Computer Learning Zone CLZ Access Excel Word Windows

Improve a mechanical device and you may double productivity. But improve man, you gain a thousandfold.

-Khan Noonien Singh
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Excel Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Loop through worksheets
Gary 

12 years ago
Alex,

That is exactly what I was looking for, with a slight modification I was able to apply the validation to a range of 12 worksheets. A thousand thanks!

'Best method!!!

Dim N As Long
Dim WS As Worksheet


For N = 1 To ThisWorkbook.Worksheets.Count - 3 'added the -3 to exclude other worksheets
    Set WS = ThisWorkbook.Worksheets(N)

With Range("A10:A14,A16:A21,A23:A33,A35:A41,A50:A54,A56:A61,A63:A73").Validation 'Apply validation to this ranges of cells
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=Key!$C$2:$C$100" 'Retrieves the list from another worksheet named keys
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
        
    End With

I did figure out an alternate with .select, however it would flip through all the worksheets when ever I opened excel. I am posting this because the.select method is all over the internet and I DO NOT!! recommend using the method below.    

Dim N As Long
For N = 1 To ThisWorkbook.Worksheets.Count - 3
    ThisWorkbook.Worksheets(N).Select

Range("A10:A14,A16:A21,A23:A33,A35:A41,A50:A54,A56:A61,A63:A73").Select
   With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="=Key!$C$2:$C$100"
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
        
    End With

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

Next Unseen

 
New Feature: Comment Live View
 
 

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 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/16/2026 1:56:29 PM. PLT: 0s