Skip to content

Instantly share code, notes, and snippets.

View OberdanBrito's full-sized avatar

Oberdan Brito OberdanBrito

View GitHub Profile
Dim flag As Boolean
flag = False
Dim linha, contador, inicio, final As Long
linha = 1
contador = 0
inicio = 0
final = 0
While Not flag
If InStr(ws.Cells(linha, 1).Value, "Empresa:") > 0 Then
Do
final = final + 1
If InStr(ws.Cells(final, 1).Value, "Empresa:") > 0 Or vazios = 10 Then Exit Do
If IsEmpty(ws.Cells(final, 1)) Then vazios = vazios + 1
Loop
Range("A" & inicio & ":K" & final - 1).Copy
Workbooks.Add
Set novoarquivo = ActiveWorkbook
Worksheets.Item(1).Name = "Planilha da fatura"
Worksheets.Item(1).Paste
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("A1").Activate
novoarquivo.SaveAs Filename:="C:\minhas_empresas\" & empresa & ".xls"
novoarquivo.Save
novoarquivo.Close
Dim pasta, textoparapesquisa, colunainicial, colunafinal, sigla As String
Dim linha, contador, inicio, final, vazios As Long
Private Sub ComboBoxArquivoOrigem_Change()
ComboBoxPlanilhaOrigem.Clear
ListaPlanilhasdoArquivo
End Sub
Private Sub OptionButtonEmpresas_Click()
TextBoxCaminhoDestino.Text = pasta & "\empresas\"