Consulting

Results 1 to 10 of 10

Thread: min value

  1. #1
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location

    min value

    Lw = Range("b2").End(xlDown).Row
    ActiveChart.Axes(xlValue).Select
    ActiveChart.Axes(xlValue).MinimumScale = Application.Min(Range("b2:B" & Lw))
    what's wrong with the code below
    ActiveChart.Axes(xlValue).MinimumScale = Application.Min(Range("b2:B" & Lw))
    Attached Images Attached Images

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    chart must be selected before running the code.
    if that's the case, what error message did you get?

    worked for me:
    With ActiveChart.Axes(xlValue)
        .MinimumScale = Application.Min(Range("B2:B" & Lw))
        .MaximumScale = Application.Max(Range("B2:B" & Lw))
    End With
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    and you dont need to select the chart....

    With Sheets("Sheet1").ChartObjects("Chart 1").Chart.Axes(xlValue)
        .MinimumScale = Application.Min(Range("B2:B" & Lw))
    End With
    modify the sheet and chart object names.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location
    Quote Originally Posted by mancubus View Post
    chart must be selected before running the code.
    if that's the case, what error message did you get?

    worked for me:
    With ActiveChart.Axes(xlValue)
        .MinimumScale = Application.Min(Range("B2:B" & Lw))
        .MaximumScale = Application.Max(Range("B2:B" & Lw))
    End With
    not working
    Lw = Range("b2").End(xlDown).Row
    Range("A2:I" & Lw).Select
    Set cht1 = ActiveSheet.Shapes.AddChart
    cht1.Chart.ChartType = xlLineMarkers
    cht1.Chart.Location xlLocationAsNewSheet
    ActiveChart.ChartArea.Select
    ActiveChart.PlotArea.Select

    Dim ValuesArray(), SeriesValues As Variant
    Dim Ctr As Integer, TotCtr As Integer
    With ActiveChart
    For Each x In .SeriesCollection
    SeriesValues = x.Values
    ReDim Preserve ValuesArray(1 To TotCtr + UBound(SeriesValues))
    For Ctr = 1 To UBound(SeriesValues)
    ValuesArray(Ctr + TotCtr) = SeriesValues(Ctr)
    Next
    TotCtr = TotCtr + UBound(SeriesValues)
    Next

    ActiveChart.FullSeriesCollection(5).Select
    ActiveChart.FullSeriesCollection(2).Delete
    ActiveChart.FullSeriesCollection(2).Delete
    ActiveChart.FullSeriesCollection(2).Delete
    ActiveChart.FullSeriesCollection(2).Delete
    ActiveChart.FullSeriesCollection(2).Delete
    ActiveChart.FullSeriesCollection(2).Delete

    With ActiveChart.Axes(xlValue)
    .MinimumScale = Application.Min(Range("B2:B" & Lw))
    .MaximumScale = Application.Max(Range("B2:B" & Lw))
    End With
    End With
    End Sub
    Attached Files Attached Files
    Last edited by asdzxc; 08-27-2014 at 01:22 AM.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why not post your workbook and tell us iun what way it doesn't work, it errors, scale not correct, what?
    ____________________________________________
    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 Contributor
    Joined
    Apr 2012
    Posts
    107
    Location
    posted.
    Book2.xlsm

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No, you told us the name but didn't link it. Go to Advanced>Manage Files.
    ____________________________________________
    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

  8. #8
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location
    Quote Originally Posted by xld View Post
    No, you told us the name but didn't link it. Go to Advanced>Manage Files.

  9. #9
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location
    Book2.xlsm attached
    Attached Files Attached Files

  10. #10
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location
    SOLVED

Posting Permissions

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