• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Re Size images within an Excel cell; Using the VBA code|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Re Size images within an Excel cell; Using the VBA code|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosRe Size images within an Excel cell…
sp_PrintTopic sp_TopicIcon
Re Size images within an Excel cell; Using the VBA code
Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
1
January 20, 2018 - 6:56 pm
sp_Permalink sp_Print

Hello everyone My name is Maurizio I write to you as: I just can not solve this problem. So: I created my weather forecasts in VBA; And so far so good. Then I created a sort of repechage of the images belonging to the forecasts. Everything happens inside my workbook. Everything seems to work beautifully; Except for a Done. That is that: When the images are positioned within the cell indicated by me. I would like the images to take the size of a particular cell. While in my case the first image completely fills the first cell plus one piece of the second. While the Second Image only partially fills the second cell and so on. For this reason I was just looking for a system to adapt them all to the corresponding cell. You have a vague idea of ​​how all this can be done, Thanks Greetings from A.Maurizio

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
2
January 22, 2018 - 12:36 pm
sp_Permalink sp_Print

Hi Maurizio

I am unable to read your file. However base on your description, you can give the attachment a try.

It contains a macro that will fit any images to a cell. you can select a range of cells.

Just make sure that the top-left hand corner of the image is within the cell.

Hope this helps.

Sunny

Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
3
January 25, 2018 - 5:40 pm
sp_Permalink sp_Print

Hello SunnyKow, I took a look at your program and it's nice; But my Zip File that I inserted in my post and a little more complicated. As: On Sheet 1 where the extraction of the HTML data of the weather forecast occurs, entries of the "Sunny" type are also reported; "Partly Cloudy" etc ...! After that it compares them not a list that is found in Sheet 2. With the VLookup Code; And found the correspondent goes to draw the image that is inside my images folder of the project itself. Only that everything works wonderful and is definitely faster than what I had given to you at first; But that fished the image through his Link. But I'm trying and trying again that also put all my knowledge, but does not want to know to insert the three images only within their cells adapting to them. That's all ! And to think that the code is this:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim rng As Range
Dim shp As Shape
Dim bln As Boolean

Set rng = Me.Range("D1:F1")

If Not Intersect(Target, rng) Is Nothing Then
If Target.Cells.Count > 1 Then Exit Sub
If Target.Value <> "" Then

For Each shp In Me.Shapes
If shp.Top = Target.Offset(11, 0).Top Then
If shp.Left = Target.Offset(11, 0).Left Then

shp.Delete
End If
End If
Next

ActiveSheet.Pictures.Insert(ThisWorkbook.Path & "\Immagini\" & Application.WorksheetFunction.VLookup(Target.Value, [Tabella], 3, 0)).Select
Selection.Top = Target.Offset(11, 0).Top
Selection.Left = Target.Offset(11, 0).Left

With ActiveSheet.Pictures
.ShapeRange.LockAspectRatio = msoFalse
.Width = Target.Offset(11, 0).Width
.Height = Target.Offset(11, 0).Height

End With

Else

For Each shp In Me.Shapes
If shp.Top = Target.Offset(11, 0).Top Then
If shp.Left = Target.Offset(11, 0).Left Then

shp.Delete

End If
End If

Next

End If
End If

Target.Select
Set rng = Nothing

Foglio1.Range("F6").Select
End Sub

Hello and thank you for your help. Sincere greetings as always from A.Maurizio

Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
4
January 31, 2018 - 6:54 pm
sp_Permalink sp_Print

Do not hold more account than this my request as I solved this problem almost by accident. Now it works wonders Thank you

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Richard West, Wesley Burchnall, Clayton Watson
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 204
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Bhuwan Devkota
Kathryn Patton
Maria Conatser
Jefferson Granemann
Glen Coulthard
Nikki Fox
Rachele Dickie
Forum Stats:
Groups: 3
Forums: 24
Topics: 6222
Posts: 27291

 

Member Stats:
Guest Posters: 49
Members: 31913
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.