tabbytomo
New Member
- Joined
- Jun 23, 2016
- Messages
- 18
Hiya, so thanks to some of you I'm 99% done with my pet project! I have only one tiny thing left that I can't for the life of me figure out.
My below code selects a range based on a criteria, copies that range, pastes it into a chart, then exports the chart as a .jpg to a specified folder. However, the charts that are created are getting in the way of some of the subsequent images. Could someone assist with me with how I move the chart out to at least column AM to keep it out the way. Current code below;
My below code selects a range based on a criteria, copies that range, pastes it into a chart, then exports the chart as a .jpg to a specified folder. However, the charts that are created are getting in the way of some of the subsequent images. Could someone assist with me with how I move the chart out to at least column AM to keep it out the way. Current code below;
VBA Code:
Sub MakeTeamSnapshot(team As Variant)
Dim PerformanceSheet As Worksheet
Set PerformanceSheet = Sheets("Flu Database 1")
Dim sh As Shape
With PerformanceSheet
.Range("$A$1:$Y$1500").AutoFilter Field:=15, Criteria1:=team
Dim tmpChart As Chart
Set sh = PerformanceSheet.Shapes(PerformanceSheet.Shapes.Count)
Set tmpChart = Charts.Add
tmpChart.ChartArea.Clear
tmpChart.Name = "PicChart" & (Rnd() * 10000)
Set tmpChart = tmpChart.Location(Where:=xlLocationAsObject, Name:=PerformanceSheet.Name)
tmpChart.ChartArea.Width = 500
tmpChart.ChartArea.Height = 800
'Paste range as image to chart
.Range("A1").CurrentRegion.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
tmpChart.ChartArea.Select
tmpChart.Paste
'Save chart image to file
Dim fileSaveName As Variant
fileSaveName = SAVE_FOLDER & Replace$(team, " ", "") & "." & SAVE_FORMAT
tmpChart.Export Filename:=fileSaveName, FilterName:=SAVE_FORMAT
'Clean up
tmpChart.Parent.Delete
End With
End Sub
Last edited: