SouthernGent0327
New Member
- Joined
- Jan 30, 2021
- Messages
- 14
- Office Version
- 365
- Platform
- Windows
So I have the following sample set:
The workbook is setup to take in data from a UserForm and formulas transfer this data to a dummy range for graphing. There are multiple ranges like shown above starting at Row 12 to 2015. Here is the current code used to generate the XY scatter Plots:
Sub NormPerm1()
Dim ws As Worksheet
Dim NormPRange As Range
Dim NormPChart As Chart
Dim LastRow As Long
Dim StartCell As Range
Set ws = ActiveSheet
Set StartCell = Range("AG12")
ActiveSheet.UsedRange
Set NormPChart = Charts.Add
LastRow = ws.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
Set NormPRange = ws.Range("AG12:AG" & LastRow & ", AH12:AH" & LastRow)
With NormPChart
.SetSourceData Source:=NormPRange
.HasTitle = True
.ChartTitle.Text = "Normalized Permeate Flow"
.ChartType = xlXYScatter
.PlotBy = xlColumns
End With
End Sub
Currently, the graphing function works, but the X-axis is arbitrarily graphing values on the X-axis. So effectively just counting the entries and not actually using the correct days of operations values. How can I make the x and y axis dynamically update as new data is added to the table? Also, is this the best way of accomplishing my goal or would an alternate method work better for this application? Thanks in advance for your time and help. Also, here is a copy of the output from the full scale table:
That x-axis should be values ranging from 13 to 600 days.
Days of Operation | Packages |
10 | 20 |
15 | 50 |
18 | 100 |
The workbook is setup to take in data from a UserForm and formulas transfer this data to a dummy range for graphing. There are multiple ranges like shown above starting at Row 12 to 2015. Here is the current code used to generate the XY scatter Plots:
Sub NormPerm1()
Dim ws As Worksheet
Dim NormPRange As Range
Dim NormPChart As Chart
Dim LastRow As Long
Dim StartCell As Range
Set ws = ActiveSheet
Set StartCell = Range("AG12")
ActiveSheet.UsedRange
Set NormPChart = Charts.Add
LastRow = ws.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
Set NormPRange = ws.Range("AG12:AG" & LastRow & ", AH12:AH" & LastRow)
With NormPChart
.SetSourceData Source:=NormPRange
.HasTitle = True
.ChartTitle.Text = "Normalized Permeate Flow"
.ChartType = xlXYScatter
.PlotBy = xlColumns
End With
End Sub
Currently, the graphing function works, but the X-axis is arbitrarily graphing values on the X-axis. So effectively just counting the entries and not actually using the correct days of operations values. How can I make the x and y axis dynamically update as new data is added to the table? Also, is this the best way of accomplishing my goal or would an alternate method work better for this application? Thanks in advance for your time and help. Also, here is a copy of the output from the full scale table:
That x-axis should be values ranging from 13 to 600 days.