nathan1981ss
New Member
- Joined
- Jun 16, 2018
- Messages
- 2
Help! my recorded macro is below. My issue is, workbook "billing.xlsm" name will vary such as: "billing 1" or "billing 2" etc.
I have tried applying solutions i have read in forums but i might be going about it wrong.
I have tried applying solutions i have read in forums but i might be going about it wrong.
Code:
[COLOR=#0000ff]Sub Auto_Copy_Invoice_From_Color()[/COLOR]
[COLOR=#0000ff]
[/COLOR]
[COLOR=#0000ff]
[/COLOR]
[COLOR=#0000ff] Range("Table12[[#Headers],[INV '#]]").Select[/COLOR]
[COLOR=#0000ff] ActiveWorkbook.Worksheets("Color").ListObjects("Table12").Sort.SortFields.Clear[/COLOR]
[COLOR=#0000ff] ActiveWorkbook.Worksheets("Color").ListObjects("Table12").Sort.SortFields.Add _[/COLOR]
[COLOR=#0000ff] Key:=Range("Table12[[#Headers],[INV '#]]"), SortOn:=xlSortOnValues, Order _[/COLOR]
[COLOR=#0000ff] :=xlDescending, DataOption:=xlSortNormal[/COLOR]
[COLOR=#0000ff] With ActiveWorkbook.Worksheets("Color").ListObjects("Table12").Sort[/COLOR]
[COLOR=#0000ff] .Header = xlYes[/COLOR]
[COLOR=#0000ff] .MatchCase = False[/COLOR]
[COLOR=#0000ff] .Orientation = xlTopToBottom[/COLOR]
[COLOR=#0000ff] .SortMethod = xlPinYin[/COLOR]
[COLOR=#0000ff] .Apply[/COLOR]
[COLOR=#0000ff] End With[/COLOR]
[COLOR=#0000ff] Rows("5:5").Select[/COLOR]
[COLOR=#0000ff] Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove[/COLOR]
[COLOR=#0000ff] Range("A6:A7").Select[/COLOR]
[COLOR=#0000ff] Range("A7").Activate[/COLOR]
[COLOR=#0000ff] Selection.AutoFill Destination:=Range("A5:A7"), Type:=xlFillDefault[/COLOR]
[COLOR=#0000ff] Range("A5:A7").Select[/COLOR]
[COLOR=#0000ff] Range("A1").Select[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] ActiveSheet.Unprotect[/COLOR]
[COLOR=#0000ff] Sheets("G702 ").Select[/COLOR]
[COLOR=#0000ff] ActiveSheet.Unprotect[/COLOR]
[COLOR=#0000ff] Sheets("G 703").Select[/COLOR]
[COLOR=#0000ff] ActiveSheet.Unprotect[/COLOR]
[COLOR=#0000ff] Range("J2").Select[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("H5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("H2").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("D5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Sheets("Billing Cover Sheet").Select[/COLOR]
[COLOR=#0000ff] Range("D5").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("B5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("D34").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("C5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Range("E5").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] ActiveCell.FormulaR1C1 = "Yes"[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("C18").Select[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("F5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("C14").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("G5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("B6").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("I5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("B7").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("J5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("D30").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("Q5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("D31").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("R5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("D22").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("S5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Range("A1").Select[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True[/COLOR]
[COLOR=#0000ff] Sheets("G702 ").Select[/COLOR]
[COLOR=#0000ff] ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True[/COLOR]
[COLOR=#0000ff] Sheets("G 703").Select[/COLOR]
[COLOR=#0000ff] ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True[/COLOR]
[COLOR=#0000ff] Sheets("Billing Cover Sheet").Select[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("A5").Select[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Windows("Billing.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _[/COLOR]
[COLOR=#0000ff] :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Windows("AR Log.xlsm").Activate[/COLOR]
[COLOR=#0000ff] Range("A1").Select[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Range("A6:S6").Select[/COLOR]
[COLOR=#0000ff] Selection.Copy[/COLOR]
[COLOR=#0000ff] Range("A5:S5").Select[/COLOR]
[COLOR=#0000ff] Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _[/COLOR]
[COLOR=#0000ff] SkipBlanks:=False, Transpose:=False[/COLOR]
[COLOR=#0000ff] Application.CutCopyMode = False[/COLOR]
[COLOR=#0000ff] Range("A1").Select[/COLOR]
[COLOR=#0000ff]End Sub[/COLOR]
Last edited by a moderator: