+ Reply to Thread
Results 1 to 4 of 4

Basic Macro Question

Hybrid View

  1. #1
    Registered User
    Join Date
    06-04-2008
    Posts
    16

    Basic Macro Question

    Sorry in advance, this should be a simple fix I just have zero experience with Macros in excel. I have this set up so far. The number of rows varies so I find the last row. I then want to plot data from columns A&B from A4 to LastRow and B4 to LastRow but am not sure how to do this. Thanks in advance

    Sub PumpingCurve()
    '
    ' PumpingCurve Macro
    '
        Dim LastRow As Long
        With ActiveSheet
            LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        End With
            ActiveSheet.Shapes.AddChart.Select
        ActiveChart.ChartType = xlXYScatter
        ActiveChart.SeriesCollection.NewSeries
        ActiveChart.SeriesCollection(1).Name = "=test2!$A$1"
        ActiveChart.SeriesCollection(1).XValues = "=test2!$A$4:$A$"
        ActiveChart.SeriesCollection(1).Values = "=test2!$B$4:$B$"
        
    End Sub

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your Thread Title should be descriptive of the question, this is covered in the Forum Rules. please read them.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862
    Just make your range:
    ActiveChart.SeriesCollection(1).Values = "=test2!A4:B" & LastRow
    The xvalues is only a row - maybe your header row? - representing what you want along the x axis.
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Is this what you want?
        ActiveChart.SeriesCollection(1).XValues = Sheet("test2").Range(Cells(4, 1), Cells(lastRow, 1))
        ActiveChart.SeriesCollection(1).Values = Sheet("test2").Range(Cells(4, 2), Cells(lastRow, 2))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Very Basic Excel Question
    By jstainer in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 08-26-2008, 05:56 AM
  2. basic vbe question
    By leon2424 in forum Excel General
    Replies: 1
    Last Post: 07-31-2008, 06:06 AM
  3. account # altering macro question
    By lilsnoop in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2008, 04:20 PM
  4. Very basic macro question (find and append)
    By Orzabal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2007, 10:38 AM
  5. Macro question
    By punter in forum Excel General
    Replies: 6
    Last Post: 11-06-2006, 03:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1