0

Thank you for your time and I hope someone can answer this problem for me, I want to copy a range containing a chart and paste it in my dashboard, a user here named Patrick was kind enough to show me the way which works great, except that the picture being pasted shows shadows like the picture below and I don't know how to correct this, the code I'm using is this:

    ActiveSheet.Pictures.Delete
    Application.ScreenUpdating = True
    Application.CutCopyMode = False
    Worksheets("Weekly Sorted").Range("N1:AA37").CopyPicture xlScreen, xlBitmap
    Application.ScreenUpdating = False
    Sheets("Dash").Select
    Range("B5").Select
    ActiveSheet.Pictures.Paste.Select

Picture one is how the chart looks like... enter image description here

And this picture is how it gets pasted... enter image description here

I'm not very familiar with technical codes, so a simple solution to this problem is highly appreciated. I tried using xlprint and xlPicture options but the picture resolution obtained were horrible.

Thanking you all in advance.

EDIT:

Thank you Tony for the help, I wasn't very clear as I tried to oversimplify things before, my code above copies a whole range of charts, tables and other info from the calculation sheet over to the dashboard, depending on which radio button is pressed, like the new picture below, sometimes there are more than 10 charts, I'm using excel 2007, do you think I can use your code for everything I need?

enter image description here

Mohd Reza
  • 53
  • 2
  • 11
  • The code I provided is just to get you started so that you can modify it as needed. It finds all “chart objects” on sheet “1” and copies a picture of each onto sheet “2“. There are many other things you can do, like specify the position of each copied picture, etc. I encourage you to learn how to use stack overflow so that you can get answers to questions which will come up. First of all, the question area is not for comments, but instead you should use this area below. Make each question as clear as possible and once it is answered reward the answerer by clicking the checkmark and up arrows. – Tony M Oct 07 '19 at 07:31
  • Thanks again Tony, I tried the code and it DOES paste the charts perfectly as I want, but on my calculation sheet, there are hundreds of charts, all next to their relevant tables, like in the picture above, using my code... – Mohd Reza Oct 10 '19 at 06:09
  • ```Worksheets("Weekly Sorted").Range("N1:AA37").CopyPicture xlScreen, xlBitmap``` will exactly copy and paste the portion that I want, where I want it pasted, but it has that negative side effect, with your code it just copies ALL charts, not the tables or the ranges, and I can't find a way to select which chart and table to copy, and where to place those when pasting, also the charts being pasted have $ signs on everything for some reason, not the KD sign in the original chart. Thanking you again for your time Tony. – Mohd Reza Oct 10 '19 at 06:09
  • If I understand, the "high quality picture problem" of your original post was solved, but now you realize that there are other things you need to learn. That's why I encouraged you "to learn how to use stack overflow so that you can get answers to questions which will come up." StackOverflow is not here to guide you step-by-step through your project, but to help with very specific technical questions which others may also encounter. I'm not criticizing you here, just trying to help you get the help you need. So I suggest you mark this picture quality question as answered & ask a new question – Tony M Oct 10 '19 at 08:27
  • But my question was not about copy/pasting a CHART, it was about copy/pasting a whole range, containing tables, charts and other items, that is what I had a problem with. Anyhow you are right in the sense that I was not clear enough, I will open a new question being more clear. Thanks again. – Mohd Reza Oct 10 '19 at 10:20

1 Answers1

1

I made a chart which seems similar to yours from the data shown at A2:A9 on Sheet "1" and then ran the code below to produce a picture from the chart pasted on sheet "2"

Option Explicit
Sub copyChartPicture()
Dim ch As ChartObject
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Worksheets("1")
Set sh2 = Worksheets("2")
For Each ch In sh1.ChartObjects
    ch.CopyPicture
    sh2.Activate
    sh2.Pictures.Paste
Next ch
End Sub

It looks identical as can be seen in the animated gif which shows me stepping through the code (click on it to get a higher quality image). I suggest you duplicate exactly what I've done to confirm it for yourself and then apply to your situation. enter image description here

Tony M
  • 1,694
  • 2
  • 17
  • 33