Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'abre wb desejado pelo usuário
- Dim fileName As Variant
- fileFilter = "XLSM (*.xlsm), *.xlsm"
- fileName = Application.GetOpenFilename(fileFilter:=fileFilter)
- 'abre o arquivo selecionado
- If fileName <> False Then
- 'desabilitar eventos previne macros do wb que você está abrindo de rodarem
- Application.EnableEvents = False
- Set wbEndividamentoTemp = Workbooks.Open(fileName)
- Application.EnableEvents = True
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- 'importa cada uma das áreas solicitadas
- 'endividamento
- If Me.check_endiv Then
- Call lerDadosTabela(wbEndividamentoTemp)
- 'copia planilha de dados do endividamento para a planilha atual
- ThisWorkbook.Sheets("Dados").Cells.Delete
- wbEndividamentoTemp.Sheets("Dados").UsedRange.Copy
- ThisWorkbook.Sheets("Dados").Cells(1, 1).PasteSpecial
- 'gera a planilha de endividamento
- Call obtemDadosEndividamento
- Call gerarTabelaEndiv
- End If
- 'dados de restriçoes
- If Me.check_restricoes Then
- ThisWorkbook.Sheets("dados_restricoes").Cells.Delete
- wbEndividamentoTemp.Sheets("dados_restricoes").UsedRange.Copy
- ThisWorkbook.Sheets("dados_restricoes").Cells(1, 1).PasteSpecial
- exibir_ligadas_sem_ap = wbEndividamentoTemp.Sheets("Restrições").Range("A1").value
- Dim dictConsultasSerasa As Dictionary
- Set dictConsultasSerasa = GetRestricoesData
- Call gerarTabelaRestricoes(exibir_ligadas_sem_ap, dictConsultasSerasa)
- End If
- 'faturamento
- If Me.check_faturamento Then
- ThisWorkbook.Sheets("Faturamento").Columns("A:X").clear
- wbEndividamentoTemp.Sheets("Faturamento").Columns("A:X").Copy
- ThisWorkbook.Sheets("Faturamento").Cells(1, 1).PasteSpecial
- End If
- 'irpf
- If Me.check_irpf Then
- ThisWorkbook.Sheets("IRPF").Cells.clear
- wbEndividamentoTemp.Sheets("IRPF").Cells.Copy
- ThisWorkbook.Sheets("IRPF").Cells(1, 1).PasteSpecial
- End If
- End If
- 'alavancagem e mcg
- If Me.check_alav_mcg Then
- Call ImportAlavMCGData
- End If
- 'fecha o arquivo original
- wbEndividamentoTemp.Close SaveChanges:=False
- ThisWorkbook.Sheets("Home").Select
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- MsgBox ("Dados importados com sucesso")
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement