Solved

Dashboard Details via "Link"

Posted on 2011-03-01
9
328 Views
Last Modified: 2012-05-11
I'm working on a Dashboard that provides a Summary of all the important information that our management needs to run our business.  I had the idea of a section last night and wanted to get some feedback as to the possibility of it.  Basically, I'll be linking to a query in an Access Database that contains all of the expense records (from Quickbooks via QODBC) for each of our departments (Sales, Marketing, etc.)  It will also have a field/column for the month.  

What I have now is a table that has departments for rows, and months for columns, that totals the records for each combination (Sales-Feb, Marketing-Jan, etc.)  

I'm wondering if it's possible to write a VBA script that, when you click on any of those combinations:
1. opens a new workbook
2. writes all of the records for that "clicked" combination

Is that possible and/if so, extremely difficult?
0
Comment
Question by:BBlu
  • 5
  • 4
9 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35010451
Yes it s possible. Could you upload a sample workbook?

Sid
0
 

Author Comment

by:BBlu
ID: 35010580
Coming up.
0
 

Author Comment

by:BBlu
ID: 35011151
This shows what I'm talking about.  Cols. A-C represent the data that I will link to/import into Excel.  The summary table will sum up the departments...and when you click on one (yellow one; Marketing/November), I want it to create a new workbook with the details behind the number.

 Dashboard-Question.xls
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 35012295
Like this? Sample File Attached.

When you click inside the table and click on the command button then the data will be exported to a file and saved to location "C:\MyFile.xls"

Sid

Code Used

Private Sub CommandButton1_Click()
    Dim i As Long, lastRow As Long
    Dim rRow As Long, cCol As Long
    Dim mMonth As Long
    Dim rng As Range
    Dim wb1 As Workbook
    Dim Dept As String
    
    '~~> Change the range to the relevant range here
    If Intersect(Selection, Range("F7:H11")) Is Nothing Then
        MsgBox "Please select the cell in the correct range"
        Exit Sub
    End If
    
    Application.ScreenUpdating = False
    
    lastRow = Range("A" & Rows.Count).End(xlUp).Row
    
    rRow = Selection.Row
    cCol = Selection.Column
    mMonth = Month(Cells(6, cCol).Value)
    Dept = Cells(rRow, 5).Value
    
    Set rng = Range("A1:C1")
    For i = 2 To lastRow
        If Month(Range("A" & i).Value) = mMonth And Range("C" & i).Value = Dept Then
           Set rng = Union(rng, Range("A" & i & ":C" & i))
        End If
    Next i
    
    Range(rng.Address).Copy
    
    Set wb1 = Workbooks.Add
    
    wb1.Sheets(1).Activate
    ActiveSheet.Paste
    
    '~~> Change the file Name Here
    wb1.SaveAs "C:\MyFile.xls"
    wb1.Close
    
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub

Open in new window

Dashboard-Question.xls
0
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.

 

Author Comment

by:BBlu
ID: 35012639
Wow!  That is awesome.  It gave me an error initially, but when I clicked "End", it still opened the file.  I changed the path, and it saved it fine.  But it then didn't open the spreadsheet automatically.  How can I add that function (back)?
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35012651
If you want to see the spreadsheet then delete the line

wb1.Close

Sid
0
 

Author Comment

by:BBlu
ID: 35012703

Man,that is fantastic!  Thanks, Sid.  People like you have really helped expedite my learning.  I have questions, I ask for help, and then I'm able to read the code to gradually learn how all of the pieces (of code) work.  Thank you very much for taking the time to help.  
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35012724
You are welcome :)

Sid
0
 

Author Closing Comment

by:BBlu
ID: 35012752
I almost feel like it's cheating getting such AMAZING and quick help.  You guys make me look like a Rock Star at work!
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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
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…

896 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

12 Experts available now in Live!

Get 1:1 Help Now