Move Shape to TopLeftCell

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
598
Office Version
  1. 2019
Platform
  1. Windows
I am running this macro, and its working great, but once it crops the image the image is in row 8, how can I get the code to move the image to the top left cell?

VBA Code:
Option Explicit
Sub CopyScreen()

Application.SendKeys "({1068})", True
DoEvents
Sheets("Sheets").Select
Cells(1, 1).Select
Sheets("Sheets").Paste
Cells(1, 1).Select
Dim shp As Shape
With ActiveSheet
    Set shp = .Shapes(.Shapes.Count)
End With

Dim h As Single, w As Single
h = -(700 - shp.Height)
w = -(500 - shp.Width)

shp.LockAspectRatio = False
shp.PictureFormat.CropRight = w
shp.PictureFormat.CropTop = h
shp.PictureFormat.CropBottom = 153
shp.TopLeftCell = True

End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
VBA Code:
shp.Top = Cells(ActiveWindow.ScrollRow, 1).Top
shp.Left = Cells(ActiveWindow.ScrollRow, ActiveWindow.ScrollColumn).Left
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top