Consulting

Results 1 to 7 of 7

Thread: Change the image size in terms of the value of a cell

  1. #1

    Change the image size in terms of the value of a cell

    hi ....
    can I Change the image size in terms of the value of a cell
    Thanks in advance

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Yes.

    This will resize in relation to the screen resolution
    [VBA]
    Option Explicit
    Option Compare Text

    Public ScrWidth&, ScrHeight&
    Declare Function GetSystemMetrics32 Lib "User32" _
    Alias "GetSystemMetrics" (ByVal nIndex&) As Long

    Sub SizePic()
    Dim SizeFactor, x
    SizeFactor = Range("A1").Value
    ActiveSheet.Shapes(1).Width = SizeFactor * (GetSystemMetrics32(0))
    End Sub
    [/VBA]
    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
    Thank you very much

    The solution was close
    I sent a file
    I hope to consider it
    Attached Files Attached Files

  4. #4

  5. #5
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    hi yahiaoui.

    Quote Originally Posted by yahiaoui
    hi ....
    can I Change the image size in terms of the value of a cell
    Thanks in advance

    and mdmackillop's code resizes your picture based on cell A1 value, as you requested.

    the problem being what?
    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)

  6. #6
    Thanks for the reply

    Quote Originally Posted by yahiaoui

    The solution was close
    I sent a file
    I hope to consider it
    I want to resize the image
    So that it appears part of the picture

  7. #7
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    what image?
    Image (ActiveX Control)?
    and load a picture to that control from worksheet?
    and change the control size to fit loaded picture?
    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)

Posting Permissions

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