Greetings everyone!
I'm working on a macro to do my daily copying/pasting for me. It works by copying data from a daily updated PivotTable and pasting it in the correct sheet/cell location.
Here's a picture of my table just to give you an idea of how my data is set up: https://paste.pics/736a2e7214ab0f103596ab4d5cf5f9b1
Here's my code:
It works in two parts by searching for a correct category "adwordsKLS" and then posting the data in the correct spot with formatting. I planned to do this with every category in my table.
My error comes from within these categories. For example, on some days the category "adwordsKLS" might not exist, causing my code to loop looking for it. I understand the error i'm just not savvy enough to figure out a work around (self-learning is hard, yikes).
Thanks Excel heroes.
I'm working on a macro to do my daily copying/pasting for me. It works by copying data from a daily updated PivotTable and pasting it in the correct sheet/cell location.
Here's a picture of my table just to give you an idea of how my data is set up: https://paste.pics/736a2e7214ab0f103596ab4d5cf5f9b1
Here's my code:
Code:
Sub TEST()'
' TEST Macro
Dim OrganicClicks As Integer
Dim OrganicLeads As Integer
Dim OrganicCons As Integer
'adwordsKLS'
Sheets("PivotTable").Select
Range("A8").Select
Do Until ActiveCell = "adwordsKLS"
ActiveCell.Offset(1, 0).Select
Loop
Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 3)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Google Search").Select
Range("D5").Select
Do Until ActiveCell = ""
ActiveCell.Offset(0, 1).Select
Loop
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
'formating'
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Font.Bold = False
'con2med'
Sheets("PivotTable").Select
Range("A8").Select
Do Until ActiveCell = "con2med"
ActiveCell.Offset(1, 0).Select
Loop
Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 3)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Misc.").Select
Range("D75").Select
Do Until ActiveCell = ""
ActiveCell.Offset(0, 1).Select
Loop
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
'formating'
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Font.Bold = False
End
It works in two parts by searching for a correct category "adwordsKLS" and then posting the data in the correct spot with formatting. I planned to do this with every category in my table.
My error comes from within these categories. For example, on some days the category "adwordsKLS" might not exist, causing my code to loop looking for it. I understand the error i'm just not savvy enough to figure out a work around (self-learning is hard, yikes).
Thanks Excel heroes.