+ 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
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    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
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    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
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    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
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    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
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    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)

Similar Threads

  1. [SOLVED] Image Resizing Issue
    By MLHansen in forum Excel General
    Replies: 7
    Last Post: 10-03-2018, 10:07 AM
  2. [SOLVED] Help resizing image - produces different image size on different computers.
    By Andrew Entee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2017, 01:47 PM
  3. resizing image in userform
    By sammu78 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 09:25 AM
  4. resizing the image in PPT using VBA
    By queryak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2012, 04:23 AM
  5. Resizing an image pasted to ppt
    By c7015 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2012, 01:21 PM
  6. Placing and resizing an image + delete existing image
    By dsheets05 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2011, 09:05 PM
  7. Resizing an image to a % value
    By Taff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-20-2005, 01:42 AM

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