+ Reply to Thread
Results 1 to 13 of 13

Click on Cell and Excel Zooms in

Hybrid View

  1. #1
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    Click on Cell and Excel Zooms in

    Hi,

    I guess the question is as is in the title. Is there any VBA Code where I can click a cell or area on the worksheet and Excel will zoom to that area?

    Regards,
    David

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Click on Cell and Excel Zooms in

    Hello kinseldd5,

    Excel automatically "takes" you to the area where you click. Do you actually mean to have the area where you "Clicked" to be enlarged - (Zoom larger)? If so, how Large would you like the area which has been Clicked, to show?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Click on Cell and Excel Zooms in

    Winon,

    Thanks for the reply. I basically want to be able to click a cell, or more importantly a chart object which when clicked (or double clicked) will, lets say for example, be zoomed to full screen. I have seen this done before but can't remember unfortunately the method put forward. Do you have any suggestions?

    Thanks.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Click on Cell and Excel Zooms in

    if you don't need to be able to select the chart for anything else you can assign this macro to it
    Sub Chart_Zoom()
        Dim rCurrSel As Range
        Set rCurrSel = Selection
        Application.ScreenUpdating = False
        With ActiveSheet.Shapes(Application.Caller)
            Application.Goto Range(.TopLeftCell, .BottomRightCell), True
        End With
        ActiveWindow.Zoom = True
        rCurrSel.Select
        Application.ScreenUpdating = True
    End Sub
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Click on Cell and Excel Zooms in

    @ JosephP,

    Hi JP,

    Thank you for helping.

    I am quite happy with that!

  6. #6
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Click on Cell and Excel Zooms in

    JosephP,

    Thanks for the reply.

    Unfortunately I do need to click the graph to get information regarding what values the lines correspond to and the axes. Would there be a method available that would only increase the chart size if double clicked and double clicking again would return to the original zoom?

    Winon I appreciate your help too

    Regards,
    David

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Click on Cell and Excel Zooms in

    Hello kinseldd5,

    Ajusting Chart sizes, increasing or decreasing, can most of the time play havoc with the Chart objects, i.e.; Font size and so on, pulling everything on the Chart askew. You can add two Buttons to the Sheet, one Button to increase the Chart to pre-defined parameters, and the other Button to decrease it to a set minimum size. (Then maybe a third Button to "Reset").

    Since I am not exactly sure as to how your Chart is set up, and what Code you have running along with it, I am afraid, I might not be able to give you a ready solution.

    There is however this one of many other sites where this topic is discussed in full length, offering many different ways of how to approach your specific requirement.

    See this link: http://peltiertech.com/Excel/Charts/...tCreation.html

    Hope that helps!

    If you have any other issues, or if you are still stuck, feel free to let us know.

  8. #8
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Click on Cell and Excel Zooms in

    Winon,

    Thanks for the reply. I looked through the link you sent and unfortunately it's not exactly what I am looking for. I did however find the below code:

    Option Explicit
    
    Dim objChartClass() As clsChart
    
    Sub SetChartObjects(wks As Worksheet)
        Dim intChartCount   As Integer
        Dim cht             As ChartObject
        
        intChartCount = 0
        For Each cht In wks.ChartObjects
            ReDim Preserve objChartClass(intChartCount)
            Set objChartClass(intChartCount) = New clsChart
            Set objChartClass(intChartCount).objChart = cht.Chart
            intChartCount = intChartCount + 1
        Next cht
        
        Set cht = Nothing
    End Sub
    I unfortunately do not understand the code and as a result am finding it difficult to implement into my workbook. Do you have any suggestions or do you understand the method in place. I really appreciate your help. Thanks a bunch.

    Regards,
    David
    Attached Files Attached Files

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Click on Cell and Excel Zooms in

    Hello kinseldd5,

    In post No.3 you state:
    I basically want to be able to click a cell, or more importantly a chart object which when clicked (or double clicked) will, lets say for example, be zoomed to full screen.
    I checked the WorkBook you have uploaded, and my golly, it works! One click on a Chart and it Zooms in, Click again and it is restored to its original size! is that not what you wanted?

    What else do you need to do?

  10. #10
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Click on Cell and Excel Zooms in

    Winon,

    I wanted to see if you noticed an issue with the coding because when I add it to my workbook it does work, as in a click a graph and it enlarges to full screen, click again and it minimises, but then I receive an error report and Excel crashes Not sure why and thought yo might be able to shed some light.

    I am sorry, probably should have mentioned this in my previous post.

    Regards,
    David

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Click on Cell and Excel Zooms in

    Hello kinseldd5,

    No sweat. For what it might be worth, I have saved it as an xlsm WorkBook in Excel 2007. I see that you are using Excel 2010, and there could be some issues there. I don't know, but please check it in this format and see if it now works on your side as well. I have no problems in xls or xlsm formats.

    Please let me know how it goes.
    Attached Files Attached Files
    Last edited by Winon; 10-01-2012 at 01:36 PM. Reason: Spelling - (I am Afrikaans)

  12. #12
    Registered User
    Join Date
    01-12-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Click on Cell and Excel Zooms in

    Winon,

    I do not know where you got the information from but I only have Excel 2007 installed on my computer so its odd that you say that? However I understand it may work on your computer but the workbook I am using that set of code in (which is filled with 100's of lines of macro code (and for work reasons I am not allowed to upload)) seems to crash when I use the chart zooming. It may just be down to the shear amount of data in the workbook and unfortunately an error code is not issued therefore I cannot reference the issue online.

    I understand having the workbook available to you you would probably sort it out very quickly but sadly I am not in a position to do so

    Regards,
    David

  13. #13
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Click on Cell and Excel Zooms in

    Hello David,

    I see that you are using Excel 2010
    That is what is showing as your "MS-Off Ver" under your name "Excel 2010". Then maybe you should change that to Excel 2007.

    Sometimes setting EnableEvents to false and/or setting Calculation to manual, all at the beginning of your Code Procedures, and then restoring it at the end, solves most of lurking problems.

+ 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