+ Reply to Thread
Results 1 to 3 of 3

Dynamic chart with macro function

  1. #1
    Registered User
    Join Date
    07-01-2013
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2010
    Posts
    3

    Question Dynamic chart with macro function

    Hello!
    I have this charts that is based on data from a web query. When I press a macro button there are different parameters I will need to put in, for example hox many hours back I wanna see (this is a chart on previous weather). The thing is, when its 24 hours it fits my chart perfectly, but when it is, say, 6 hours, the chart will still use the data from all the same cells as when it was 24, hence my chart will have a lot of "REF!" points up to 6 hours ago.

    How will I be able to make my chart dynamic so I can change the time parameters as it suits the situation?

    If something came off as unclear, just ask. Thanks in advance!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Dynamic chart with macro function

    Hi,

    One way would be to create a dynamic range name for your chart data which automatically adjusts to the number of relevant rows and then use that range name as the source for your chart.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Dynamic chart with macro function

    It would help us understand better if you could attach a copy of your work or macro. Just remove any sensitive data and feed in the basic dummy values so that we can understand the calculations.
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  4. #4
    Registered User
    Join Date
    07-01-2013
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Dynamic chart with macro function

    Hello codeslizer, this is the macro:

    Sub Refresh()
    '
    ' Refresh Macro
    '

    '

    ActiveWorkbook.RefreshAll
    Sheets("Used data").Select

    MsgBox "Here is your METAR data from " & Range("V6").Value & "!"


    End Sub

    and here is the temperature at the moment with 24 hours as one of the paramters:
    Air Temp Dew Point
    110350 9 8
    110250 9 8
    110150 9 8
    110050 9 8
    102350 9 7
    102250 9 8
    102150 10 8
    102120 10 8
    102050 11 8
    102020 11 8
    101950 11 8
    101920 11 8
    101850 12 8
    101820 12 8
    101750 13 8
    101720 13 8
    101650 13 8
    101620 13 8
    101550 13 9
    101520 13 8
    101450 13 8
    101420 13 8
    101350 14 8
    101320 14 8
    101250 14 8
    101220 14 9
    101150 14 9
    101120 14 9
    101050 14 8
    101020 14 9
    100950 14 8
    100920 13 8
    100850 13 8
    100820 13 8
    100750 13 8
    100720 13 8
    100650 12 9
    100620 12 8
    100550 12 8
    100520 11 8
    100450 11 8
    100420 10 8

    Thanks Richrad, I wil try that!

  5. #5
    Registered User
    Join Date
    07-01-2013
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Dynamic chart with macro function

    Hello codeslizer, this is the macro:

    Sub Refresh()
    '
    ' Refresh Macro
    '

    '

    ActiveWorkbook.RefreshAll
    Sheets("Used data").Select

    MsgBox "Here is your METAR data from " & Range("V6").Value & "!"


    End Sub

    and here is the temperature at the moment with 24 hours as one of the paramters:
    Air Temp Dew Point
    110350 9 8
    110250 9 8
    110150 9 8
    110050 9 8
    102350 9 7
    102250 9 8
    102150 10 8
    102120 10 8
    102050 11 8
    102020 11 8
    101950 11 8
    101920 11 8
    101850 12 8
    101820 12 8
    101750 13 8
    101720 13 8
    101650 13 8
    101620 13 8
    101550 13 9
    101520 13 8
    101450 13 8
    101420 13 8
    101350 14 8
    101320 14 8
    101250 14 8
    101220 14 9
    101150 14 9
    101120 14 9
    101050 14 8
    101020 14 9
    100950 14 8
    100920 13 8
    100850 13 8
    100820 13 8
    100750 13 8
    100720 13 8
    100650 12 9
    100620 12 8
    100550 12 8
    100520 11 8
    100450 11 8
    100420 10 8

    Thanks Richrad, I wil try that!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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