I am working on a project where a large amount of data is stored in an excel workbook, with a new sheet for every quarter. I need need to create a dashboard of the data which shows graphs of data from the last 4 quarters. I have set a dropdown to select the quarter and am attempting to pull the relevant data through from the source sheets to the dashboard sheet but I just can't get it to work.
Private Sub SelectionChange(ByVal Target As Range) Dim Q4 As Integer, Q1 As Integer, Q2 As Integer, Q3 As Integer, selectedQ As Variant 'read selected quarter selectedQ = ActiveSheet.Range("B3").Value 'compare selected quarter to identify sheet index 'Q4 is current quarter If selectedQ = "15-16 Q4" Then Q4 = 10 Else If selectedQ = "16-17 Q1" Then Q4 = 11 Else If selectedQ = "16-17 Q2" Then Q4 = 12 Else If selectedQ = "16-17 Q3" Then Q4 = 13 Else If selectedQ = "16-17 Q4" Then Q4 = 14 Else If selectedQ = "17-18 Q1" Then Q4 = 15 Else If selectedQ = "17-18 Q2" Then Q4 = 16 Else If selectedQ = "17-18 Q3" Then Q4 = 17 Else If selectedQ = "17-18 Q4" Then Q4 = 18 Else If selectedQ = "18-19 Q1" Then Q4 = 19 Else End If 'set sheet index for previous quarters If Q4 > 3 Then Q3 = Q4 - 1 Q2 = Q4 - 2 Q1 = Q4 - 3 End If 'fill current quarter using Sheets(1).Range(1, 1) as source 'under 3 reg ActiveSheet.Range("C10").Value = Sheets(Q4).Range("Z21").Value ActiveSheet.Range("C11").Value = Sheets(Q4).Range("Z29").Value ActiveSheet.Range("C12").Value = Sheets(Q4).Range("Z39").Value ActiveSheet.Range("C13").Value = Sheets(Q4).Range("Z50").Value ActiveSheet.Range("C14:C19").Value = Sheets(Q4).Range("Z60:Z65").Value End Sub I initially started this project on a mac but have also tried to debug this on windows office 2007. When I watch the variable selectedQ on the PC it shows the message "can't compile module". What am I missing?
Thanks in advance
Iain
ActiveSheetis the one whose cell "B3" you have to pick value from. you'd better use some fully qualified name likeWorksheets("MySheet").Range("B3")