Solved

Dashboard Details via "Link"

Posted on 2011-03-01
9
325 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

744 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

10 Experts available now in Live!

Get 1:1 Help Now