Solved

Excel cell colors into Access table

Posted on 2014-11-05
7
287 Views
Last Modified: 2014-12-03
Hi,

I have a monthly excel workbook files for several years, each with 1-31 worksheets.  Each worksheet is a daily schedule with 10 machines as columns B-K and 30 minute time slots between 8AM and 10PM as rows 4-32.  Each day essentially has 280 data elements.  When the machine is used the cell color is changed to one of several colors depending on the process that was used.

I need to get this data into an MS Access table for analysis.

Table structure is : ID, DateTime, MachineNo, ProcessNo
ID=PK Autonumber

I think I can loop through the worksheets, then the cells but how do I read the cell color using vba and scan the data?

Thanks in advance.

Bill
0
Comment
Question by:Bill Ross
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 40423679
Hi,

the color property is found under

Range.Interior.Color

Regards
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40423757
or you can use Range.Interior.ColorIndex, which may be more user friendly.
0
 
LVL 14

Author Comment

by:Bill Ross
ID: 40423764
Hi Phillip,

I don't work much with Excel vba - mostly Access.  So do I define a range as a single cell, read the color and then go to the next cell?  Can you give me some sample code to get me started?

Thanks,

Bill
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40423796
The following code will copy the ColorIndex of columns B-K, rows 1-10000, into columns AB-AK. Make sure you have saved your spreadsheet before running this code, and you cannot undo it.

Sub ExtractColours()
For intcol = 2 To 11
    For introw = 1 To 10000
        Cells(introw, intcol + 26) = Cells(introw, intcol).Interior.ColorIndex
    Next
Next
End Sub

Open in new window


The above code assumes by "color" you mean "background color".

For a translation of the numbers issued by ColorIndex, see this page: http://msdn.microsoft.com/en-us/library/office/ff840443(v=office.15).aspx

(-4142 means "no color").
0
 
LVL 14

Author Comment

by:Bill Ross
ID: 40423801
Hi Phillip,

OK.  I'll give it a try.

Thanks,

Bill
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40478141
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question