Good day to everyone-
As a newcomer to VBA, and I'm trying to come up with a more efficient solution to the Macro in which I am currently using. This macro takes performance data which has been dumped into excel, and creates a standardized line graph from it, as well as addresses some other formatting issues. I have attached a workbook which displays the correct/standardized manner in which I would like to format the graph (Sheet1), as well as the graph my macro creates (Sheet2).
Also, if anyone has any tips or suggestions on ways to more efficiently create the below code, it would be sincerely appreciated.
Sheets("Sheet2").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = "Date"
With Selection
.HorizontalAlignment = xlLeft
End With
Sheets("Sheet1").Select
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("A1:A6"), ActiveSheet.UsedRange)
Application.ScreenUpdating = False
For Each cell In rng
If (cell.Value) Like "PERFORMANCE HISTORY" Then
Set del = cell
del.Offset(12, 2).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Sheet2").Select
Range("A3").Select
ActiveSheet.Paste
End If
Next cell
'Name of Portfolio
Sheets("Sheet1").Select
Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) Like "PERFORMANCE HISTORY" Then
Set del = cell
del.Offset(2, 0).Select
Selection.Copy
Sheets("Sheet2").Select
Range("IV2").Select
Selection.End(xlToLeft).Offset(0, 1).Select
ActiveSheet.Paste
Selection.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=RC[-1]&"" Index"""
End If
Sheets("Sheet1").Select
Next cell
'Pull Performance
Sheets("Sheet1").Select
Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) Like "PERFORMANCE HISTORY" Then
Set del = cell
del.Offset(13, 3).Select
Range(Selection, Selection.Offset(0, 1)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Sheet2").Select
Range("IV4").Select
Selection.End(xlToLeft).Offset(0, 1).Select
ActiveSheet.Paste