Solved

Dashboard Details via "Link"

Posted on 2011-03-01
9
331 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

827 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