I need help with writing a fully qualified macro code.

Juno123

New Member
Joined
Jun 21, 2011
Messages
10
I need help with writing a fully qualified macro code for the following code snippet-
Sub Test()
Dim ChObj As ChartObject
Dim Top As Double
Dim Left As Double
Application.ScreenUpdating = False
For Each ChObj In ActiveSheet.ChartObjects
Top = ChObj.Top
Left = ChObj.Left
ChObj.Cut
ActiveSheet.Pictures.Paste.Select
Selection.Top = Top
Selection.Left = Left
Next ChObj
Range("A1").Select
Application.ScreenUpdating = True
End Sub
 
You cannot move a range, which is what the selection is after pasting. Try:
Code:
With wsReport.Pictures.Paste
   .Top = Top
   .Left = Left
End With

instead of:
Code:
wsReport.Pictures.Paste.Select
Selection.Top = Top
Selection.Left = Left
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
There is no top property on a range it's available on the list but not relevent and will cause a compile error when you think of a range (cells) it makes sense, generally if you cut and paste without moving the paste is where the cut was
 
Upvote 0
Excellent !!! That solved my latest problem.. Thanks Rorya...

I will tell you more about the random errors that I have been getting a bit later as I have certain deliverables right now.

I have joined this forum for the first time and I already find it very useful..
Thanks a bunch Rorya..
 
Upvote 0
There is no top property on a range it's available on the list but not relevent and will cause a compile error

That is not true - there is a Top property but it is read only, so you can't change it. It is very useful for positioning shapes and charts etc on a worksheet so that they line up with a particular range (along with the Left, Width and Height properties)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,719
Members
452,939
Latest member
WCrawford

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