Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. Dim i As Long
  2. Dim iLastRow As Long
  3. Dim Cells As Range
  4.  
  5. 'This section looks up each group name on the tab and cycles through the loop
  6. Application.ScreenUpdating = False
  7.  
  8. With ActiveSheet
  9. iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
  10. For i = 4 To iLastRow - 1 'Group names start in A5
  11.  
  12. 'Selects, copies, and pastes the next group name in the list
  13. Sheets("Groups").Select
  14. ActiveSheet.Cells(i + 1, 1).Copy
  15. Range("A1").Select
  16. Selection.PasteSpecial paste:=xlPasteValues
  17.  
  18. 'Selects, copies, and pastes the group logo onto the bubble
  19. ActiveSheet.Shapes.Range(Array("Picture 7")).Select
  20. Selection.CopyPicture xlScreen, xlPicture
  21. ActiveSheet.ChartObjects("Chart 6").Activate
  22. ActiveChart.FullSeriesCollection(2).Select
  23. Selection.paste
  24.  
  25. 'Variables needed for directory and file names
  26. GroupName = Sheets("Groups").Range("A1")
  27. yearmo = Sheets("Groups").Range("A2")
  28.  
  29. 'Will create a new folder for the final images if it doesn't already exist
  30. If Len(Dir("DirPath" & yearmo, vbDirectory)) = 0 Then
  31. MkDir "DirPath" & yearmo
  32. End If
  33.  
  34. 'Set up image file names
  35. Dim NewFileName As String
  36. NewFileName = "" & yearmo & " - " & GroupName & " - X_Y.jpg"
  37.  
  38. 'Selects and saves the bubble chart as a JPG
  39. ActiveChart.ChartArea.Select
  40. ActiveChart.Export "DirPath" & yearmo & NewFileName
  41.  
  42. Next i
  43. End With
  44.  
  45. 'After all individual bubble have been created, need to
  46. 'set up state file name to generate image with all logos for the state
  47. Dim StateFileName As String
  48. StateFileName = "" & yearmo & " - STATE - X_Y.jpg"
  49.  
  50. 'Selects and saves the state bubble chart as a JPG
  51. ActiveSheet.ChartObjects("Chart 4").Activate
  52. ActiveChart.Export "DirPath" & yearmo & StateFileName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement