Filter by Week and Switch Between Scatter and Line Charts in Excel
Question details
Create an interactive chart that filters data by week and switches between a scatter chart and a line chart with markers.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user wants to select a week and choose how the matching data is plotted.
- Observed behavior
- The chart should update for the selected week and display either numeric X values in a scatter chart or categories in a line chart.
Arrange the data in columns for Week, X, and Y, and check that the X values are numeric if you plan to use a scatter chart. The FILTER formulas below require an Excel version that supports dynamic arrays; the chart-switching macro requires desktop Excel.
Use filtered helper ranges and two switchable Excel charts
Use a week selector to update both charts, then use a chart-type selector and VBA to show the chosen chart.
This example assumes weeks are in A2:A100, X values are in B2:B100, and Y values are in C2:C100 on Sheet1. Adjust the ranges and sheet name to match your workbook.
A scatter chart uses numeric X-axis spacing. A line chart treats its horizontal-axis labels as categories, so uneven numeric intervals are not represented proportionally.
Select D1, open Data > Data Validation, and create a List containing All and the available week values. Create another List in G1 with Scatter and Line as its choices.
In E2, enter =FILTER(B2:B100,(A2:A100<>"")*((D1="All")+(A2:A100=D1)>0),NA()). In F2, enter =FILTER(C2:C100,(A2:A100<>"")*((D1="All")+(A2:A100=D1)>0),NA()). Select a week in D1 to test the results.
Open Formulas > Name Manager > New. Create workbook-level names FilteredX referring to =Sheet1!$E$2# and FilteredY referring to =Sheet1!$F$2#. Replace Sheet1 with your actual sheet name.
Use Insert > Scatter to create a scatter chart and Insert > Line > Line with Markers to create a line chart. In Chart Design > Select Data, set the scatter series X and Y values to the FilteredX and FilteredY names, and set the line chart's horizontal-axis labels and series values to those same names. Qualify each name with your workbook name when entering it, for example ='Book1.xlsx'!FilteredX.
Open Home > Find & Select > Selection Pane and rename the chart objects WeekScatter and WeekLine. Place the charts in the same position so either one can occupy the chart area.
Press Alt+F11, open the code module for Sheet1, and add: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Me.Range("G1")) Is Nothing Then Exit Sub Me.ChartObjects("WeekScatter").Visible = (Me.Range("G1").Value = "Scatter") Me.ChartObjects("WeekLine").Visible = (Me.Range("G1").Value = "Line") End Sub. Save as an Excel Macro-Enabled Workbook (.xlsm), enable macros if you trust the file, and change G1 to test the switch.

Filter weekly data and change chart types in WPS Spreadsheet
Use WPS Spreadsheet to filter the source rows by week and change the chart between scatter and line formats. This is a manual alternative to the Excel selector-and-macro setup.
- 1. Open the workbook: Open WPS Spreadsheet and select Open to load the workbook containing the Week, X, and Y columns.
- 2. Filter by week: Select the data range, choose Data > Filter, and use the Week column's filter arrow to select the desired week.
- 3. Insert a chart: Select the X and Y data and use Insert > Chart to create a scatter chart. Check that the chart displays the filtered rows; if hidden rows are still plotted, check the chart's hidden-data settings or chart the filtered results in a separate range.
- 4. Change the chart type: Select the chart and use Chart Tools or right-click the chart and choose Change Chart Type. Select Line with Markers to switch views, or choose Scatter to switch back.

Frequently Asked Questions
Should I use a scatter chart or a line chart for weekly data?
Use a scatter chart when numeric X values and their spacing matter. Use a line chart with markers when the horizontal axis represents discrete weeks or categories.
How can I show every week in the Excel chart?
Choose All in the D1 week selector. The example FILTER formulas then return all rows with a nonblank week.
Why does the chart show no data for a selected week?
Check that the D1 selection matches a value in the Week column. If no rows match, the example FILTER formulas return #N/A; choose another week or All.
Can I switch the Excel charts without enabling macros?
Yes. Create both charts and manually show or select the one you want. The G1 selector only switches their visibility automatically when the VBA macro is enabled in desktop Excel.




