Computer Learning Zone CLZ Access Excel Word Windows

Wisdom... comes not from age, but from education and learning.

-Anton Chekhov
 
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
Alex Hedley 
            
15 years ago
Hi Gary,

So this list of values changes?
Will it always be A1, B1, C1 and down without spaces?

If you select the first cell and then run
  Range(Selection, Selection.End(xlDown)).Select
this does the same as Ctrl + Shift + Down highlighting every cell until there are no more with content in them.
Now you can use a loop that goes through each cell and store the value.

Here's some code to get you started:

Sub Macro16()

    Dim Colours() As String ' declares a dynamic array variable
    
    Range(Selection, Selection.End(xlDown)).Select
    NoOfCells = Selection.Count
    
    ReDim Colours(1 To NoOfCells) ' declares the array variable with the necessary size
    
    lCount = 1
    For Each CurCell In Selection
        Colours(lCount) = CurCell.Interior.ColorIndex
        lCount = lCount + 1
    Next CurCell
    
    For Each Colour In Colours()
        MsgBox Colour
    Next Colour
    
End Sub


Try repeating the code with the column of case statements then you can join the two arrays assigning the colours to cases...

Regards
Alex

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/17/2026 2:13:48 PM. PLT: 1s