Results 1 to 1 of 1

Macro to plot graph based on date from inputbox

Threaded View

  1. #1
    Registered User
    Join Date
    07-21-2012
    Location
    London, englan
    MS-Off Ver
    Excel 2007
    Posts
    7

    Macro to plot graph based on date from inputbox

    Hello everyone,

    I am writing a macro to plot a graph based on the date entered into the InputBox. When the date is entered it filters the data based on the date, then I want to select all the data in for that particular date in rows c and d to graph.

    I am getting errors in the bold below while I am trying to figure this out. The current error is "Run-time error 91 on line myDate = Range(Selection, Selection.End(xlDown)).Select . Object variable or With block variable not set". I searched the error online without any luck of fixing the error. Can someone please help me with this?


    Dim SDate As String
    Dim myDate As Range
    
    Sheet5.Select
    SDate = InputBox(prompt:="Please enter date MM/DD/YYYY", Title:="Plot Graph by Date")
        'Terminates here if empty
        If SDate = Empty Then Exit Sub
        'Continues here if not empty...
        ActiveSheet.Range("$A$1:$L$99999").AutoFilter Field:=2, Operator:= _
            xlFilterValues, Criteria2:=Array(2, SDate)
        'Add new sheet at end and rename
        Sheets.Add After:=Sheets(Sheets.Count)
        Sheets(Sheets.Count).Select
        Sheets(Sheets.Count).Name = InputBox("Please enter the new sheet name i.e. AMT Depth MM DD")
        'Add line chart from selected data
        ActiveSheet.Shapes.AddChart.Select
        Sheet5.Select
        Range("C2:D3").Select
         Range(Selection, Selection.End(xlDown)).Select
       myDate = Range(Selection, Selection.End(xlDown)).Select
        Set myDate = myDate.Select
        ActiveChart.SetSourceData Source:=Sheet5.Range(myDate), PlotBy:=xlColumns
        ActiveChart.ChartType = xlLine
    Jordan
    Last edited by reesjordan; 12-31-2013 at 07:10 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro Help...Plot Graph based on Cell Value
    By dksodhi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2012, 08:54 AM
  2. Excel Macro- To plot graph based on the selected data
    By jaycribs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2012, 09:52 AM
  3. Excel Macro- To plot graph based on the selected data
    By jaycribs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-19-2012, 02:53 PM
  4. VBA code to plot date and time on Xaxis of scatter graph
    By Balachan56 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 10-14-2011, 11:13 AM
  5. Macro to plot chart based on date time and data
    By stormlab in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-05-2011, 12:04 PM

Tags for this Thread

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