Solved

Excel VBA chart array

Posted on 2010-11-08
2
609 Views
Last Modified: 2012-05-10
Hello Experts,

I need some help to populate two similar chart matrix using VBA. I'm not too sure how approach this. I need to loop within a recordset and build a string to populate a matrix, which depends upon two criteria. This should make more sense if you look at the attached example.

Any help and suggestions are very much appreciated
Employee-Rating.xls
0
Comment
2 Comments
 
LVL 18

Accepted Solution

by:
krishnakrkc earned 500 total points
ID: 34085786
Hi,

Unmerge the cells on Ratings sheet.

and try this macro.

Kris
Sub kTest()
    Dim k, M(1 To 3, 1 To 3), F(1 To 3, 1 To 3)
    Dim i   As Long, c As Long, r As Long
    
    k = Sheets("Data").UsedRange.Resize(, 3)
    
    For i = 2 To UBound(k, 1)
        Select Case k(i, 3)
            Case Is <= 3
                r = 1: c = k(i, 3)
            Case Is <= 6
                r = 2: c = k(i, 3) - 3
            Case Else
                r = 3: c = k(i, 3) - 6
        End Select
        If k(i, 2) = "Male" Then
            M(r, c) = IIf(Len(M(r, c)), M(r, c) & ", " & k(i, 1), k(i, 1))
        Else
            F(r, c) = IIf(Len(F(r, c)), F(r, c) & ", " & k(i, 1), k(i, 1))
        End If
    Next
    [c3:e5].Value = M
    [h3:j5].Value = F
End Sub

Open in new window

0
 

Author Closing Comment

by:lancegallagher_expertsexchange
ID: 34087615
Thanks very much, this works great!!

Sorry about the slow response, the network went down
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tags from access to excel 3 28
how to read all the sheets in excel 12 42
Copy value from a certain cell 5 24
Auto populate in Cascade dropdown 3 27
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now