VBA Automatic Plotting Help

junglekingmowgli

New Member
Joined
Jan 21, 2011
Messages
2
Hi Everyone,

I am fairly new to VBA coding, and I needed some simple help. For my x-axis, I want to select time. For my Y-axis, I want to select temperature. This data is already provided to me.

I want to plot the data using scatter of line graph options. The problem arises because the data sets do not have equal number of rows. For example, 1 data set will have 200 rows and another 300. Thus, I need a VBA code that will select the data (last row) automatically and plot it.

All your help would be greatly appreciated.

Thank you!
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,516
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
if your using 2003 you can create a macro that records your actions to get the chart as you want it, then, the code can be tweaked to extend the range
 

junglekingmowgli

New Member
Joined
Jan 21, 2011
Messages
2
I should have been more clear. I am running 2007. I tried to record it, but it only selects the same data range every time. I need help in writing the commant to automatically select the last data row.

Thanks!
 

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,516
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
This is useable, and configurable

Code:
Sub LastRowInOneColumn()
'Find the last used row in a Column: column A in this example
    Dim LastRow As Long
    With ActiveSheet
        LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    End With
    MsgBox LastRow
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,943
Messages
5,525,771
Members
409,663
Latest member
littleriver

This Week's Hot Topics

Top