Consulting

Results 1 to 15 of 15

Thread: Dynamic diagramm

  1. #1
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location

    Dynamic diagramm

    Hey guys!

    I need some help at developing a dynamic diagram (1st time).
    There is a column with the date (daily), status for the workday (1 = workday) and the respective 3 key indicators for the diagram.
    The main problem is that I need only the last 20 workdays, with the current date as the start line.
    How can a manage this?

    I think it's a combination of a when and today function but I cant handle this.

    Do you have some help or any advice?

    Here is a sample map.


    Best regards!


    DiagramDraft.xlsxDiagramDraft.xlsx

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I've added a dynamic range name and a macro to update the chart.
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,072
    Location
    I have a "method or data member not found" error. Is this something not found in Excel 2011?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Ted
    Are you referring to my post?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Aussiebear View Post
    I have a "method or data member not found" error. Is this something not found in Excel 2011?
    Excel 2011? Mac? Lot's not found in Mac Excel VBA.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location
    Hey mdmackillop!
    Thanks for your approach (:
    It's working but it's not exactly what I'm looking for (:

    The diagram should present the last 20 workdays. A workday is declared with the status 1 in the Colum B.


    Is this possible without VBA?
    I was thinking about something like that:

    Last Row: If Today (Column A) = 1 (Column B), Then show
    Row 19= If Today (Column A)-1 = 1 (Column B), Then show
    Row 18= If Today (Column A)-2 = 1 (Column B), Then show

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Best I can do without VBA. There is a hidden column (F) and data in cells behind the chart. Data used is highlighted with CF
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location
    I'm sorry mdm,

    Its the same result like the one before.
    There are also no workdays (status 0) in the diagram. It should present only real workdays (status 1).
    Furthermore, it should present the last 20 workdays, not the next 20 workdays.

    Maybe an extra table with the respective data (last 20 workdays) will solve the problem.

    Have anyone an idea?

  9. #9
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Use Workday formula to list only workdays
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  10. #10
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location
    Quote Originally Posted by mdmackillop View Post
    Use Workday formula to list only workdays
    Many many thanks!

    It's working super (:
    But I need the second column with the workday(status) as I have shown in the sample file.
    There are some workdays at the weekend for special days terms in the year.
    Is this possible to include it in your approach?


    With best regards

  11. #11
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    No need for column B. Just insert a row at the appropriate position and enter the date manually. The succeeding formulae should adjust automatically.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  12. #12
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location
    Okay cool, but I need for further research also the Not-Workdays.
    The column with the status is necessary.

    Please excuse me for saying this vaguely

  13. #13
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Similar to the earlier version. Autofilter is used to conceal non-workdays.
    Attached Files Attached Files
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  14. #14
    VBAX Regular
    Joined
    Jan 2017
    Location
    Warsaw
    Posts
    70
    Location
    Quote Originally Posted by mdmackillop View Post
    Similar to the earlier version. Autofilter is used to conceal non-workdays.
    Thanks for your new approach, mdmackillop!

    But it's not working with this structure. I need a clear structure, a clear original date set, as it is presented/ structured.
    Of course, there could be new columns.

    Maybe it's possible to create a table with the last 20 workdays.

    The last row presents the current date
    The last row -1 presents the last date -1 if it's a workday.
    And so on.
    Maybe a combination of Vlookup, When, today and workday-function.

    Does someone have any idea?

  15. #15
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    herre is a copy of a routine that I wrote to work out the last 260 working days including taking account of Bank holidays.
    The holiday dates are listed in column A of sheet "Lsehols"
    I thought this might be close to what you want:

    Sub Datelist()Sheets("Lsehols").Select
    Bankhols = Range(Cells(1, 1), Cells(77, 1))
    
    
    Sheets("Dates").Select
    inarr = Range(Cells(1, 1), Cells(274, 1))
    
    
    
    
    indi = 0
    
    
    today = Date
     If Weekday(today, vbMonday) > 5 Then
       today = today - 1
     End If
     If Weekday(today, vbMonday) > 5 Then
       today = today - 1
     End If
    For i = 274 To 14 Step -1
     Dayval = False
     Do While Dayval = False
     Cday = today - indi
     
     If Weekday(Cday, vbMonday) > 5 Then
         indi = indi + 1
     Else
        Bankhol = False
        For jj = 1 To 77
         If Cday = Bankhols(jj, 1) Then
           indi = indi + 1
           Bankhol = True
           Exit For
         End If
        Next jj
            Dayval = Not (Bankhol)
     End If
     Loop
     inarr(i, 1) = today - indi
     indi = indi + 1
    Next i
    
    
    Sheets("Dates").Select
    Range(Cells(1, 1), Cells(274, 1)) = inarr
    
    
    End Sub

Posting Permissions

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