Boa tarde,
Uma forma de fazer isso é utilizando o 'Application.GetOpenFilename'.
Anexe uma planilha de exemplo, assim fica mais fácil ajudar.
att,
Segue em anexo os arquivos que vou usar.
onde pretendo criar a macro, arquivo macro dash1, ao apertar no primeiro Botão ele executa a seguinte macro:
Sub juntar()
'
' juntar Macro
'
'
Sheets("Base Dados").Select
Columns("I:I").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I2").Select
ActiveCell.FormulaR1C1 = "AG+CNPJ"
Range("I3").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-3],""_"",(RC[-1]+0))"
Selection.AutoFill Destination:=Range("I3:I75000")
Range("I3:I75000").Select
Range("I1").Select
Sheets("Base Dados").Select
Columns("J:J").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("J2").Select
ActiveCell.FormulaR1C1 = "AG_PA"
Range("J3").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-4],""_"",RC[-3])"
Selection.AutoFill Destination:=Range("J3:J75000")
Range("I3:J75000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("J1").Select
Selection.AutoFilter
Selection.AutoFilter
MsgBox "Base Pronta com sucesso."
End Sub
após isso, ao executar o segundo botão ele deverá fazer:
1- preciso que ele execute a macro que ele pedira para eu escolher o segundo arquivo;
2 - copiar as abas todas para o arquivo macro dash 1;
3- fecha o arquivo que foi copiado;
4- executar uma macro que já funciona que adiciona um tipo de filtro em todas estas abas.
5 msg de executado corretamente.
ou
1- preciso que ele execute a macro que ele pedira para eu escolher o segundo arquivo;
2 - executar uma macro que já funciona que adiciona um tipo de filtro em todas as abas
3- fecha o arquivo que foi trabalhado;
4- mensagem de executado corretamente.
A macro que já funciona seria esta:
Sub Dashbord()
'
' Dashbord Macro
'
'
Sheets("Boarding").Select
Columns("O:O").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("O1").Select
ActiveCell.FormulaR1C1 = "AG+CNPJ"
Range("O2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-6],""_"",(RC[-13]+0))"
Selection.AutoFill Destination:=Range("O2:O5000")
Range("O2:O5000").Select
Range("O1").Select
Sheets("Boarding").Select
Columns("P:P").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("P1").Select
ActiveCell.FormulaR1C1 = "AG_PA"
Range("P2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],'Base Dados'!C9:C10,2,0)"
Selection.AutoFill Destination:=Range("P2:P5000")
Range("o2:P5000").Select
Range("O2:P5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("J1").Select
Selection.AutoFilter
Selection.AutoFilter
Sheets("Pendentes").Select
Columns("P:P").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("P1").Select
ActiveCell.FormulaR1C1 = "AG_PA"
Range("P2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-12],'boarding'!C1:C16,16,0)"
Selection.AutoFill Destination:=Range("P2:P5000")
Range("P2:P5000").Select
Range("p2:p5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("J1").Select
Selection.AutoFilter
Selection.AutoFilter
Sheets("cancelados").Select
Columns("k:k").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("k1").Select
ActiveCell.FormulaR1C1 = "AG_PA"
Range("k2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-10],'boarding'!C1:C16,16,0)"
Selection.AutoFill Destination:=Range("k2:k5000")
Range("k2:k5000").Select
Range("k2:k5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("J1").Select
Selection.AutoFilter
Selection.AutoFilter
Sheets("faturamento acm").Select
Columns("O:O").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("O1").Select
ActiveCell.FormulaR1C1 = "AG_PA"
Range("O2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-14],'boarding'!C1:C16,16,0)"
Selection.AutoFill Destination:=Range("O2:O5000")
Range("O2:O5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("j1").Select
Selection.AutoFilter
Selection.AutoFilter
Sheets("churn").Select
Columns("r:r").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("r1").Select
ActiveCell.FormulaR1C1 = "AG_PA"
Range("r2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-17],'boarding'!C1:C16,16,0)"
Selection.AutoFill Destination:=Range("r2:r5000")
Range("r2:r5000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("J1").Select
Selection.AutoFilter
Sheets("faturamento dia").Select
Columns("h:h").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("h1").Select
ActiveCell.FormulaR1C1 = "AG_PA"
Range("h2").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7],'boarding'!C1:C16,16,0)"
Selection.AutoFill Destination:=Range("h2:h20000")
Range("h2:h20000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter
MsgBox "Dashboarding pronto."
End Sub
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 18/04/2018 9:39 am