+ Reply to Thread
Results 1 to 10 of 10

VBA Help - image resizing

  1. #1
    Registered User
    Join Date
    04-08-2019
    Location
    Norfolk, England
    MS-Off Ver
    MS16
    Posts
    8

    VBA Help - image resizing

    In the attached spreadsheet, the VBA is set to resize the image in D4, based on the values entered in A1 (w) and A2 (h), this is the code used:

    Please Login or Register  to view this content.
    What i would like to do is ensure the image does not exceed the cell (D4) regardless of the height & width values - so resize locking the aspect ratio.

    Can someone help me please
    Attached Files Attached Files
    Last edited by AliGW; 07-11-2019 at 08:04 AM. Reason: Code tags added

  2. #2
    Valued Forum Contributor KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    1,095

    Re: VBA Help - image resizing

    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Registered User
    Join Date
    04-08-2019
    Location
    Norfolk, England
    MS-Off Ver
    MS16
    Posts
    8

    Re: VBA Help - image resizing

    Thank you, this works. but i would like it to do more.
    Is it possible to display the image, reflecting the size values, but keeping it withing the cell D4.

    For example, at the moment, the above works up to the value of 1500 for Height & Width. but the moment you enter a higher value ie 2100 h with 1500 w, the image remains the same. What i would like is for the image to display the relative shape, in this instance it would be a rectangle.
    Does this make sense?

  4. #4
    Valued Forum Contributor KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    1,095

    Re: VBA Help - image resizing

    English is not my native language, so maybe I don't understand something.
    Do You want to resize shape into bigger than cell size and still keep it fit into this cell?

  5. #5
    Registered User
    Join Date
    04-08-2019
    Location
    Norfolk, England
    MS-Off Ver
    MS16
    Posts
    8

    Re: VBA Help - image resizing

    Yes exactly - this is so the image displayed appears relative to the size input in the width and height.

  6. #6
    Valued Forum Contributor KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    1,095

    Re: VBA Help - image resizing

    I am still confused, sorry. If image will be bigger than D4 can't fit into cell.

  7. #7
    Registered User
    Join Date
    04-08-2019
    Location
    Norfolk, England
    MS-Off Ver
    MS16
    Posts
    8

    Re: VBA Help - image resizing

    Ignore the last, i have just increased the size of Cell D4. One last question if you can help - is there a way to ensure the image remains in the centre of the cell and resizes from the centre point?

    Thank you for all your help on this so far

  8. #8
    Valued Forum Contributor KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    1,095

    Re: VBA Help - image resizing

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-08-2019
    Location
    Norfolk, England
    MS-Off Ver
    MS16
    Posts
    8

    Re: VBA Help - image resizing

    Awesome - thank you so much. you have been a great help.

  10. #10
    Valued Forum Contributor KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    1,095

    Re: VBA Help - image resizing

    You welcome. Happy to help.
    Thanks for rep.

+ 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