Ir ao conteúdo
  • Cadastre-se

mateusmarona

Membro Pleno
  • Posts

    27
  • Cadastrado em

  • Última visita

posts postados por mateusmarona

  1. Bom dia!

     

    Não estou conseguindo entende como faço para criar novo tópico,por isso respondo por este.

     

    Estou precisando de uma macro de pesquisa que procure um valor "não exato" na planilha "Entregas" - range ("A:U"), pode ser uma palavra chave ou parte de uma palavra.

     

    A macro que tenho hoje já faz a primeira parte,ou seja, ela encontra o valor, se houver alguma correspondência.

     

    Porém se a macro não encontra nenhuma correspondência, ela dá erro.

     

    Gostaria que fosse feita uma correção na mesma e que isto gerasse uma mensagem de "valor não encontrado".

     

    Segue macro abaixo:

     

    Sub PesquisaNotaFiscalemEntregas()

    Dim Procurar As String

    Dim localizado, EndPrimeiroItem
    Application.ScreenUpdating = False
    Procurar = InputBox("Digite a Nota Fiscal procurada", "Localizar Registro de Agendamento")
    If Procurar = "" Then Exit Sub
    Sheets("Entregas").Select
    With Sheets("Entregas").Range("a:u")
    Set localizado = .Find(Procurar, LookIn:=xlValues, LookAt:=xlPart)
    localizado.Offset(0, 0).Select

    End With


    End Sub
     

     

    Valeu!  Fico no aguardo.

     

     

     

  2. Bom dia!

     

    Estou retomando este tópico pois preciso de ajuda e não estou conseguindo encontrar a opção de criar novo tópico, por mais besta que pareça, hehehe...

     

     

    Preciso desenvolver uma macro que faça a seguinte função:

     

    A aba "DBI 971" consta um relatório de pedidos em trânsito, que compreende o range A1 até o H e a quantidade de linhas varia de acordo com o dia.

     

    Na coluna E, consta o código de cada Transportadora responsável por cada entrega.

     

    Preciso que a macro possua uma caixa de texto para que eu escolha a transportadora pelo número, e assim que eu der OK, a macro filtre o relatório pelo código escolhido e envie um email automático contendo um texto padrão, um assunto padrão que mude a data de acordo com o dia do envio, cole o relatório no email, e mande este email para uma lista específica de emails cadastrados de acordo com o código da transportadora que consta em outra aba.

     

     

    Exemplo do email:

     

    _______________________________________________________________________________________

    ASSUNTO: ENTREGAS EM ATRASO - __/___/____ (data muda de acordo com o dia)

    EMAIL:

     

    Prezados (as),

     

    Segue abaixo relatório de Notas Fiscais que ainda constam como pendentes de entrega na data de hoje.

     

    COLAR AQUI O RELATÓRIO (MANTENDO FORMATAÇÃO)

     

    Favor detalhar informações na coluna "H - Transportadora" (negrito e itálico).

     

    Caso alguma destas Notas Fiscais já esteja entregue, favor enviar EDI de entrega para [email protected]

     

    Conto com sua compreensão.

     

    Aguardo retorno.

     

    Atenciosamente,

     

    Distribuidora Memphis Ltda

    Transportes

    _________________________________________________________________________________________________________

     

    Segue relatório em anexo.

    teste.xlsx

  3. Márcio, boa tarde.

     

    Serve sim, importou direitinho, porém gostaria que verificasse a possibilidade de adicionar uma informação que consta nos arquivos txt, porém não foram consideradas.

     

    A coluna CIA representa cada unidade de faturamento da empresa, sendo assim, cada arquivo importado tem uma CIA específica para as notas fiscais.

     

    que o arquivo txt tem uma informação bem no início, que é a Companhia.

     

    Seria importante que a macro considerasse este dado para cada txt importado.

     

    Ou seja, se em um dos arquivos tiver a Companhia 807, a coluna C da aba Importação deve preencher todas as notas com este dado.

     

    Desde já agradeço muito pelo help, tá ficando show...


    Márcio, um detalhe.

     

    Ao rodar um txt com número alto de linhas, 150.000, a macro deu erro.

     

    Veja se consegue descobrir do que se trata.

    post-654793-0-30036200-1423849072_thumb.

    808.rar

  4. Boa tarde, Basole.

     

    O número grifado em vermelho é o número de linhas do TXT, e ele aparece várias vezes na macro, tanto que quando quero rodá-la eu substituo todos os números que determinam o máximo de linhas por um maior ou menor, dependendo do arquivo gerado.

     

    O que eu precisava é que a macro rodasse e fizesse todas suas ações, porém sem limitar o range, de maneira a macro poder identifica sozinha o número máximo de linhas, tornando ela automática.

     

    E eu não posso rodar ela no Access porque toda a empresa utiliza este relatório e eu não posso mudar seu formato, eu apenas quero um meio de torná-la mais inteligente e fluida.

  5. Bom dia.

     

    Obrigado pelo retorno.

     

    Segue em anexo o arquivo txt e o resultado da macro em Excel.

     

    Cada CIA representa um CNPJ de faturamento, sendo assim preciso extrair um txt para cada, e o número de linhas depende do volume de faturamento.

     

    Na CIA801, geralmente o txt retorna em torno de 15000 linhas, porém tenho outras CIAD que geram até 100.000 linhas.

     

    Para não ficar ajustando manualmente e perdendo tempo, seria ótimo se a macro fosse realmente mais enxuta e identificasse sozinho a quantidade de linhas que serão utilizadas.

     

    Desde já agradeço, espero que consigam me ajudar.

    801.txt

    801.rar

  6. Bom dia.

     

    Preciso corrigir a macro abaixo, tornando o range ilimitado, ou melhor, fazendo com que a macro não limite o range a ser utilizado, pois sempre que preciso rodar ela tenho que definir qual a última linha que quero, e isto acaba me impedindo de tornar esta macro realmente prática.

     

    Realmente agradeço a quem puder ajudar.

     

    Segue:

    Sub CIA_801()    ChDir "C:\users\mateus\Desktop\Eficiência de entregas"    Workbooks.OpenText Filename:= _        "C:\users\mateus\Desktop\Eficiência de entregas\801.txt", Origin:= _        xlWindows, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, _        4), Array(10, 1), Array(11, 1), Array(20, 1), Array(21, 1), Array(30, 1), Array(51, 1), _        Array(52, 1), Array(55, 1), Array(56, 1), Array(58, 1), Array(59, 1), Array(84, 1), Array( _        85, 4), Array(95, 1), Array(101, 1), Array(102, 4), Array(112, 1), Array(118, 1), Array(119 _        , 1), Array(123, 1), Array(144, 1), Array(145, 4), Array(155, 1), Array(156, 1), Array(162, _        1), Array(163, 1), Array(171, 1), Array(172, 4), Array(182, 1), Array(188, 1), Array(189, 2 _        )), TrailingMinusNumbers:=True    Cells.Select    With Selection.Font        .Name = "Calibri"        .Size = 9        .Strikethrough = False        .Superscript = False        .Subscript = False        .OutlineFont = False        .Shadow = False        .Underline = xlUnderlineStyleNone        .ThemeColor = xlThemeColorLight1        .TintAndShade = 0        .ThemeFont = xlThemeFontMinor    End With    Range("A1").Select    ActiveCell.FormulaR1C1 = "Data Emissão"    Range("C1").Select    ActiveCell.FormulaR1C1 = "NF"    Range("E1").Select    ActiveCell.FormulaR1C1 = "PN"    Range("F1").Select    ActiveCell.FormulaR1C1 = "Cliente"    Range("H1").Select    ActiveCell.FormulaR1C1 = "Orig"    Range("J1").Select    ActiveCell.FormulaR1C1 = "Dest"    Range("L1").Select    ActiveCell.FormulaR1C1 = "Cidade"    Range("N1").Select    ActiveCell.FormulaR1C1 = "Data Import"    Range("Q1").Select    ActiveCell.FormulaR1C1 = "Data OC"    Range("T1").Select    ActiveCell.FormulaR1C1 = "Cód OC"    Range("U1").Select    ActiveCell.FormulaR1C1 = "Descrição da Ocorrência"    Range("W1").Select    ActiveCell.FormulaR1C1 = "Previsão Entrega"    Range("Y1").Select    ActiveCell.FormulaR1C1 = "Prazo Padrão"    Range("AA1").Select    ActiveCell.FormulaR1C1 = "Usuário"    Range("AC1").Select    ActiveCell.FormulaR1C1 = "Data Acordada"    Range("AF1").Select    ActiveCell.FormulaR1C1 = "Texto"    Range("B:B,D:D,G:G,I:I,K:K,M:M,O:O,P:P,R:R,S:S,V:V").Select    Range("V1").Activate    ActiveWindow.SmallScroll ToRight:=8    Range("B:B,D:D,G:G,I:I,K:K,M:M,O:O,P:P,R:R,S:S,V:V,X:X,Z:Z,AB:AB").Select    Range("AB1").Activate    ActiveWindow.SmallScroll ToRight:=7    Range("B:B,D:D,G:G,I:I,K:K,M:M,O:O,P:P,R:R,S:S,V:V,X:X,Z:Z,AB:AB,AD:AD,AE:AE"). _        Select    Range("AE1").Activate    Selection.Delete Shift:=xlToLeft    Columns("A:A").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("A1").Select    ActiveCell.FormulaR1C1 = "Cia"    Range("A2").Select    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[7]),RC[7],R[-1]C)"    Range("A2").Select    Selection.AutoFill Destination:=Range("A2:A65000"), Type:=xlFillDefault    Range("A2:A85000").Select    Cells.Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Range("A1").Select    Application.CutCopyMode = False    Columns("B:B").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("A1").Select    ActiveCell.FormulaR1C1 = "Dpto"    Range("B1").Select    ActiveCell.FormulaR1C1 = "Cia"    Range("B2").Select    ActiveCell.FormulaR1C1 = _        "=IF(ISNA(VLOOKUP(RC[-1],'[Eficiência de Entregas.xlsm]Dpto'!C1:C3,3,FALSE)),""?"",VLOOKUP(RC[-1],'[Eficiência de Entregas.xlsm]Dpto'!C1:C3,3,FALSE))"    Range("B2").Select    Selection.AutoFill Destination:=Range("B2:B85000"), Type:=xlFillDefault    Range("B2:B85000").Select    Columns("C:C").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("C1").Select    ActiveCell.FormulaR1C1 = "NF"    Range("C2").Select    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[2]),RC[2],R[-1]C)"    Range("C2").Select    Selection.AutoFill Destination:=Range("C2:C85000"), Type:=xlFillDefault    Range("C2:C85000").Select    Columns("A:A").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("A1").Select    ActiveCell.FormulaR1C1 = "Linha"    Range("A2").Select    ActiveCell.FormulaR1C1 = "1"    Range("A3").Select    ActiveCell.FormulaR1C1 = "2"    Range("A2:A3").Select    Selection.AutoFill Destination:=Range("A2:A85000"), Type:=xlFillDefault    Range("A2:A85000").Select    Columns("B:B").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("B1").Select    ActiveCell.FormulaR1C1 = "Linha Real"    Range("B2").Select    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[5]),RC[-1],9999999999)"    Range("B2").Select    Selection.AutoFill Destination:=Range("B2:B85000"), Type:=xlFillDefault    Range("B2:B85000").Select    Cells.Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Application.CutCopyMode = False    Range("A1").Select    Columns("F:F").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("F1").Select    ActiveCell.FormulaR1C1 = "Emissão"    Range("F2").Select    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[1]),RC[1],R[-1]C)"    Range("F2").Select    Selection.AutoFill Destination:=Range("F2:F85000"), Type:=xlFillDefault    Range("F2:F85000").Select    Columns("F:F").Select    Selection.NumberFormat = "dd/mm/yy;@"    Columns("A:F").Select    Range("F1").Activate    With Selection.Interior        .Pattern = xlSolid        .PatternColorIndex = xlAutomatic        .Color = 65535        .TintAndShade = 0        .PatternTintAndShade = 0    End With    Columns("S:S").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("S1").Select    ActiveCell.FormulaR1C1 = "Previsão Entrega"    Range("S2").Select    ActiveCell.FormulaR1C1 = _        "=IF(ISNUMBER(RC[-1]),WORKDAY(RC[-13],RC[1],'[Eficiência de Entregas.xlsm]Feriados'!R2C1:R85000C1),"""")"    Range("S2").Select    Selection.AutoFill Destination:=Range("S2:S85000"), Type:=xlFillDefault    Range("S2:S85000").Select    Selection.NumberFormat = "dd/mm/yy;@"    Cells.Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Application.CutCopyMode = False    Columns("R:R").Select    Selection.Delete Shift:=xlToLeft    Range("R1").Select    Columns("F:F").Select    Selection.Cut    Columns("E:E").Select    Selection.Insert Shift:=xlToRight    Columns("G:G").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("G1").Select    ActiveCell.FormulaR1C1 = "PN"    Range("H1").Select    ActiveCell.FormulaR1C1 = "Cliente"    Range("I1").Select    ActiveCell.FormulaR1C1 = "Orig"    Range("J1").Select    ActiveCell.FormulaR1C1 = "Dest"    Range("K1").Select    ActiveCell.FormulaR1C1 = "Cidade"    Range("G2").Select    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[5]),RC[7],R[-1]C)"    Range("H2").Select    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[4]),RC[7],R[-1]C)"    Range("I2").Select    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[3]),RC[7],R[-1]C)"    Range("J2").Select    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[2]),RC[7],R[-1]C)"    Range("K2").Select    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[1]),PROPER(RC[7]),R[-1]C)"    Range("G2:K2").Select    Selection.AutoFill Destination:=Range("G2:K85000"), Type:=xlFillDefault    Range("G2:K85000").Select    Columns("A:K").Select    Range("K1").Activate    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Range("K1").Select    Application.CutCopyMode = False    Columns("W:W").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("W1").Select    ActiveCell.FormulaR1C1 = "Descrição da Ocorrência"    Range("W2").Select    ActiveCell.FormulaR1C1 = _        "=IF(ISNUMBER(RC[-2]),VLOOKUP(RC[-2],'[Eficiência de Entregas.xlsm]OCs'!C1:C2,2,FALSE),"""")"    Range("W2").Select    Selection.AutoFill Destination:=Range("W2:W85000"), Type:=xlFillDefault    Range("W2:W85000").Select    Columns("W:W").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Columns("V:V").Select    Application.CutCopyMode = False    Selection.Delete Shift:=xlToLeft    Range("V1").Select    Columns("W:W").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("W1").Select    ActiveCell.FormulaR1C1 = "Finaliza Entrega"    Range("W2").Select    ActiveCell.FormulaR1C1 = _        "=IF(ISNUMBER(RC[-2]),VLOOKUP(RC[-2],'[Eficiência de Entregas.xlsm]OCs'!C1:C4,4,FALSE),"""")"    Range("W2").Select    Selection.AutoFill Destination:=Range("W2:W85000"), Type:=xlFillDefault    Range("W2:W85000").Select    Columns("W:W").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Range("W1").Select    Columns("W:W").EntireColumn.AutoFit    Application.CutCopyMode = False    Columns("X:X").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("X1").Select    ActiveCell.FormulaR1C1 = "Abona Atraso"    Range("X2").Select    ActiveCell.FormulaR1C1 = _        "=IF(ISNUMBER(RC[-3]),IF(RC[-5]<=RC[1],VLOOKUP(RC[-3],'[Eficiência de Entregas.xlsm]OCs'!C1:C4,3,FALSE),""Não""),"""")"    Range("X2").Select    Selection.AutoFill Destination:=Range("X2:X85000"), Type:=xlFillDefault    Range("X2:X85000").Select    Columns("X:X").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Application.CutCopyMode = False    Range("X1").Select    Columns("D:D").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("D1").Select    ActiveCell.FormulaR1C1 = "Cia+NF"    Range("D2").Select    ActiveCell.FormulaR1C1 = "=RC[1]&""-""&RC[3]"    Range("D2").Select    Selection.AutoFill Destination:=Range("D2:D85000"), Type:=xlFillDefault    Range("D2:D85000").Select    Columns("D:D").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    ActiveWindow.SmallScroll ToRight:=3    Columns("AD:AD").Select    Application.CutCopyMode = False    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("AD1").Select    ActiveCell.FormulaR1C1 = "Texto"    Range("AD2").Select    ActiveCell.FormulaR1C1 = "=IF(R[-1]C[-26]=RC[-26],R[-1]C&"" ""&RC[1],RC[1])"    Range("AD2").Select    Selection.AutoFill Destination:=Range("AD2:AD85000"), Type:=xlFillDefault    Range("AD2:AD85000").Select    Columns("AD:AD").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Columns("AD:AD").Select    Application.CutCopyMode = False    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("AD1").Select    ActiveCell.FormulaR1C1 = "Fim"    Range("AD2").Select    ActiveCell.FormulaR1C1 = "=IF(R[1]C[-26]<>RC[-26],""Fim do Texto"","""")"    Range("AD2").Select    Selection.AutoFill Destination:=Range("AD2:AD85000"), Type:=xlFillDefault    Range("AD2:AD85000").Select    Columns("AD:AD").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Range("AD1").Select    Columns("E:E").Select    Application.CutCopyMode = False    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("E1").Select    ActiveCell.FormulaR1C1 = "Cia+NF+Fim do Texto"    Range("E2").Select    ActiveCell.FormulaR1C1 = _        "=IF(RC[26]=""Fim do Texto"",RC[-1]&""-""&RC[26],"""")"    Range("E2").Select    Selection.AutoFill Destination:=Range("E2:E85000"), Type:=xlFillDefault    Range("E2:E85000").Select    Columns("E:E").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Range("E1").Select    ActiveWindow.SmallScroll ToRight:=12    Range("AE1").Select    Application.CutCopyMode = False    Columns("AF:AF").Select    Selection.Replace What:= _        "---------------------------------------------------  --------------------------------------------------- Texto ---------------------------------------------------" _        , Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:= _        False, SearchFormat:=False, ReplaceFormat:=False    Selection.Replace What:="   ", Replacement:=" ", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="   ", Replacement:=" ", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="   ", Replacement:=" ", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="   ", Replacement:=" ", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="  ", Replacement:=" ", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="  ", Replacement:=" ", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Columns("AF:AF").Select    Range("AF16").Activate    Selection.Replace What:= _        "--------------------------------------------------- ---------------------------------------------------" _        , Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:= _        False, SearchFormat:=False, ReplaceFormat:=False    Selection.Replace What:="---------------------------------------------------" _        , Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:= _        False, SearchFormat:=False, ReplaceFormat:=False    Columns("AF:AF").Select    Selection.Replace What:="0  Texto", Replacement:="", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="  Texto", Replacement:="", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Columns("AF:AF").Select    Selection.Replace What:="  ", Replacement:="", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="  ", Replacement:="", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="  ", Replacement:="", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="  ", Replacement:="", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Selection.Replace What:="  ", Replacement:="", LookAt:=xlPart, _        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _        ReplaceFormat:=False    Range("AF1").Select'EXCLUSÃO DAS COLUNAS FINAIS    Columns("AC:AC").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("AC1").Select    ActiveCell.FormulaR1C1 = "Texto"    Range("AC2").Select    ActiveCell.FormulaR1C1 = _        "=IF(RC[-5]=""OCORRENCIA MANUAL"",IF(IF(ISNA(VLOOKUP(RC[-25]&""-Fim do Texto"",C[-24]:C[4],29,FALSE)),"""",VLOOKUP(RC[-25]&""-Fim do Texto"",C[-24]:C[4],29,FALSE))=0,"""",IF(ISNA(VLOOKUP(RC[-25]&""-Fim do Texto"",C[-24]:C[4],29,FALSE)),"""",VLOOKUP(RC[-25]&""-Fim do Texto"",C[-24]:C[4],29,FALSE))),"""")"    Range("AC2").Select    Selection.AutoFill Destination:=Range("AC2:AC85000"), Type:=xlFillDefault    Range("AC2:AC85000").Select    Columns("AC:AC").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Cells.Select    Range("M1").Activate    Application.CutCopyMode = False    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Range("AD1").Select    Application.CutCopyMode = False    Columns("AD:AK").Select    Selection.Delete Shift:=xlToLeft    Range("AC1").Select' CHECA SE FINALIZA ENTREGA/ABONA ATRASO?    Columns("G:G").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("G1").Select    ActiveCell.FormulaR1C1 = "Cia+NF+Entregue?"    Range("G2").Select    ActiveCell.FormulaR1C1 = "=IF(RC[19]=""Sim"",RC[-3]&""-""&RC[19],"""")"    Range("G2").Select    Selection.AutoFill Destination:=Range("G2:G85000"), Type:=xlFillDefault    Range("G2:G85000").Select    Columns("G:G").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Application.CutCopyMode = False    Columns("H:H").Select    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove    Range("H1").Select    ActiveCell.FormulaR1C1 = "Cia+NF+Abona?"    Range("H2").Select    ActiveCell.FormulaR1C1 = "=IF(RC[20]=""Sim"",RC[-4]&""-""&RC[20],"""")"    Range("H2").Select    Selection.AutoFill Destination:=Range("H2:H85000"), Type:=xlFillDefault    Range("H2:H85000").Select    Columns("H:H").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Range("H1").Select    Application.CutCopyMode = False'EXCLUSÃO DE DADOS    Columns("P:V").Select    Selection.Delete Shift:=xlToLeft    Columns("I:O").Select    With Selection.Interior        .Pattern = xlNone        .TintAndShade = 0        .PatternTintAndShade = 0    End With    ActiveWindow.ScrollColumn = 2    ActiveWindow.ScrollColumn = 1    Range("A1:X1").Select    With Selection.Interior        .PatternColorIndex = xlAutomatic        .ThemeColor = xlThemeColorDark1        .TintAndShade = -0.149998474074526        .PatternTintAndShade = 0    End With    Range("I1").Select'REFAZER CHAVE DE BUSCA P/TEXTOS    Range("E2").Select    ActiveCell.FormulaR1C1 = _        "=IF(RC[14]=""OCORRENCIA MANUAL"",RC[-1]&""-Texto"","""")"    Range("E2").Select    Selection.AutoFill Destination:=Range("E2:E85000"), Type:=xlFillDefault    Range("E2:E85000").Select    Columns("E:E").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Range("E1").Select    Application.CutCopyMode = False    Range("E1").Select    ActiveCell.FormulaR1C1 = "Cia+NF+Texto"'FILTRO AVANÇADO E FORMATAÇÃO    Columns("A:X").Select    Range("A1:X85000").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _        Workbooks("Eficiência de Entregas.xlsm").Sheets("Filtro").Range("A1:A2"), _        CopyToRange:=Range("AA1"), Unique:=True    Columns("A:Z").Select    Selection.Delete Shift:=xlToLeft    Columns("A:H").Select    With Selection        .HorizontalAlignment = xlLeft        .VerticalAlignment = xlBottom        .WrapText = False        .Orientation = 0        .AddIndent = False        .IndentLevel = 0        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    Range("I:I,P:P,Q:Q").Select    Range("Q1").Activate    Range("I:I,P:P,Q:Q,V:V").Select    Range("V1").Activate    Selection.NumberFormat = "dd/mm/yy;@"    With Selection        .HorizontalAlignment = xlCenter        .VerticalAlignment = xlBottom        .WrapText = False        .Orientation = 0        .AddIndent = False        .IndentLevel = 0        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    Cells.Select    Range("H1").Activate    With Selection        .VerticalAlignment = xlCenter        .WrapText = False        .Orientation = 0        .AddIndent = False        .IndentLevel = 0        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    Range("J:L,X:X,S:S,O:O").Select    Range("O1").Activate    With Selection        .HorizontalAlignment = xlLeft        .VerticalAlignment = xlCenter        .WrapText = False        .Orientation = 0        .AddIndent = False        .IndentLevel = 0        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    Range("M:N,P:Q,T:U").Select    Range("T1").Activate    With Selection        .HorizontalAlignment = xlCenter        .VerticalAlignment = xlCenter        .WrapText = False        .Orientation = 0        .AddIndent = False        .IndentLevel = 0        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    Columns("W:W").Select    With Selection        .HorizontalAlignment = xlLeft        .VerticalAlignment = xlCenter        .WrapText = False        .Orientation = 0        .AddIndent = False        .IndentLevel = 0        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    With Selection        .HorizontalAlignment = xlCenter        .VerticalAlignment = xlCenter        .WrapText = False        .Orientation = 0        .AddIndent = False        .IndentLevel = 0        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    Rows("1:1").Select    Range("H1").Activate    With Selection        .VerticalAlignment = xlCenter        .WrapText = True        .Orientation = 0        .AddIndent = False        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    Selection.RowHeight = 27.5    Columns("A:X").Select    Range("X1").Activate    Columns("A:X").EntireColumn.AutoFit    Range("L1").Select    Columns("O:O").ColumnWidth = 12    Columns("S:S").ColumnWidth = 20    Columns("X:X").Select    Selection.ColumnWidth = 25    Selection.ColumnWidth = 45    Range("X1").Select    Range("A2").Select    ActiveWindow.FreezePanes = True    ActiveWindow.DisplayGridlines = False    Application.PrintCommunication = False    With ActiveSheet.PageSetup        .PrintTitleRows = "$1:$1"        .PrintTitleColumns = ""    End With    Application.PrintCommunication = True    ActiveSheet.PageSetup.PrintArea = "$I$1:$X$888888"    Application.PrintCommunication = False    With ActiveSheet.PageSetup        .LeftHeader = ""        .CenterHeader = ""        .RightHeader = ""        .LeftFooter = ""        .CenterFooter = ""        .RightFooter = ""        .LeftMargin = Application.InchesToPoints(0.393700787401575)        .RightMargin = Application.InchesToPoints(0.393700787401575)        .TopMargin = Application.InchesToPoints(0.393700787401575)        .BottomMargin = Application.InchesToPoints(0.393700787401575)        .HeaderMargin = Application.InchesToPoints(0.393700787401575)        .FooterMargin = Application.InchesToPoints(0.393700787401575)        .PrintHeadings = False        .PrintGridlines = False        .PrintComments = xlPrintNoComments        .PrintQuality = 600        .CenterHorizontally = True        .CenterVertically = False        .Orientation = xlLandscape        .Draft = False        .PaperSize = xlPaperA4        .FirstPageNumber = xlAutomatic        .Order = xlDownThenOver        .BlackAndWhite = False        .Zoom = False        .FitToPagesWide = 1        .FitToPagesTall = 18888        .PrintErrors = xlPrintErrorsDisplayed        .OddAndEvenPagesHeaderFooter = False        .DifferentFirstPageHeaderFooter = False        .ScaleWithDocHeaderFooter = True        .AlignMarginsHeaderFooter = True        .EvenPage.LeftHeader.Text = ""        .EvenPage.CenterHeader.Text = ""        .EvenPage.RightHeader.Text = ""        .EvenPage.LeftFooter.Text = ""        .EvenPage.CenterFooter.Text = ""        .EvenPage.RightFooter.Text = ""        .FirstPage.LeftHeader.Text = ""        .FirstPage.CenterHeader.Text = ""        .FirstPage.RightHeader.Text = ""        .FirstPage.LeftFooter.Text = ""        .FirstPage.CenterFooter.Text = ""        .FirstPage.RightFooter.Text = ""    End With    Application.PrintCommunication = True    Range("I2").Select    Columns("A:H").Select    Selection.EntireColumn.Hidden = True    Range("I1").Select'GERAR A ABA GERENCIAL    Sheets("801").Select    Sheets("801").Name = "801-COMPLETO"    Sheets("801-COMPLETO").Select    Sheets("801-COMPLETO").Copy Before:=Sheets(1)    Sheets("801-COMPLETO (2)").Select    Sheets("801-COMPLETO (2)").Move After:=Sheets(2)    Sheets("801-COMPLETO (2)").Select    Sheets("801-COMPLETO (2)").Name = "801-GERENCIAL"    Cells.Select    Selection.EntireColumn.Hidden = False    Columns("A:X").Select    ActiveSheet.Range("$A$1:$X$85000").RemoveDuplicates Columns:=4, Header:= _        xlYes    Columns("A:C").Select    Selection.Delete Shift:=xlToLeft    Columns("B:E").Select    Selection.Delete Shift:=xlToLeft    Range("A1").Select'FAZE FINAL DA ABA GERENCIAL    Range("I1").Select    ActiveCell.FormulaR1C1 = "Data Entrega"    Range("I2").Select    ActiveCell.FormulaR1C1 = _        "=IF(ISNA(VLOOKUP(RC[-8]&""-Sim"",'801-COMPLETO'!C[-2]:C[8],11,FALSE)),""Pendente"",VLOOKUP(RC[-8]&""-Sim"",'801-COMPLETO'!C[-2]:C[8],11,FALSE))"    Range("I2").Select    Selection.AutoFill Destination:=Range("I2:I85000"), Type:=xlFillDefault    Range("I2:I85000").Select    Columns("I:I").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Range("J1").Select    Application.CutCopyMode = False    ActiveCell.FormulaR1C1 = "Abona Atraso?"    Range("J2").Select    ActiveCell.FormulaR1C1 = _        "=IF(ISNA(VLOOKUP(RC[-9]&""-Sim"",'801-COMPLETO'!C[-2]:C[7],10,FALSE)),""Não"",""Sim"")"    Range("J2").Select    Selection.AutoFill Destination:=Range("J2:J85000"), Type:=xlFillDefault    Range("J2:J85000").Select    Range("K1").Select    ActiveCell.FormulaR1C1 = "Data do Abono"    Range("K2").Select    ActiveCell.FormulaR1C1 = _        "=IF(ISNA(VLOOKUP(RC[-10]&""-Sim"",'801-COMPLETO'!C[-3]:C[6],10,FALSE)),""n/a"",VLOOKUP(RC[-10]&""-Sim"",'801-COMPLETO'!C[-3]:C[6],10,FALSE))"    Range("K2").Select    Selection.AutoFill Destination:=Range("K2:K85000"), Type:=xlFillDefault    Range("K2:K85000").Select    Columns("I:K").Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Columns("L:N").Select    Application.CutCopyMode = False    Selection.Delete Shift:=xlToLeft    Range("N2").Select    ActiveCell.FormulaR1C1 = _        "=IF(ISNA(VLOOKUP(RC[-13]&""-Texto"",'801-COMPLETO'!C[-9]:C[10],20,FALSE)),"""",VLOOKUP(RC[-13]&""-Texto"",'801-COMPLETO'!C[-9]:C[10],20,FALSE))"    Range("N2").Select    Selection.AutoFill Destination:=Range("N2:N85000"), Type:=xlFillDefault    Range("N2:N85000").Select    Cells.Select    Selection.Copy    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _        :=False, Transpose:=False    Columns("A:A").Select    Application.CutCopyMode = False    Selection.Delete Shift:=xlToLeft    Range("A1").Select'EXCLUSÃO FINAL    Columns("H:K").Select    Selection.ColumnWidth = 8    Selection.NumberFormat = "dd/mm/yy;@"    With Selection        .HorizontalAlignment = xlGeneral        .Orientation = 0        .AddIndent = False        .IndentLevel = 0        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    With Selection        .HorizontalAlignment = xlCenter        .Orientation = 0        .AddIndent = False        .IndentLevel = 0        .ShrinkToFit = False        .ReadingOrder = xlContext        .MergeCells = False    End With    Columns("A:M").Select    Range("A1:M85000").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _        Workbooks("Eficiência de Entregas.xlsm").Sheets("Filtro").Range("B1:B2"), _        CopyToRange:=Range("Z1"), Unique:=False    Columns("A:M").Select    Selection.Copy    Columns("Z:AL").Select    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _        SkipBlanks:=False, Transpose:=False    Application.CutCopyMode = False    Columns("A:Y").Select    Selection.Delete Shift:=xlToLeft    Range("A1").SelectEnd Sub

    Abraço

  7. Boa noite.

     

    Estou num grande dilema.

     

    Tenho um relatório que preciso rodar uma vez por semana, via excel.

     

    Os dados extraídos do sistema em formato txt, e importados e organizados em uma planilha por meio de uma macro gigante.

     

    Estes arquivos txt variam no número de linhas toda vez que preciso rodar o relatório, e geralmente preciso acessar a macro e alterar o range manualmente.

     

    Por exemplo, tenho nesta macro diversas vezes o número 15.000, que neste caso é o limite máximo de linhas utilizado de range, ("A2:A15000"), então eu substituo o 15000 (300 resultados na macro) pelo número de linhas resultantes no txt, que pode ser até 120.000 linhas.

     

    O problema é que, para a macro rodar mais leve, preciso fazer esta alteração 5 vezes, pois extraio 5 txts diferentes.

     

    Existe um meio de uma macro acessar esta macro e me permitir alterar o range, através de caixa de texto para eu informar o número que eu quero, ou a macro procurar pelo número de linhas necessárias, evitando o trabalho manual?

     

    Posso postar o código aqui depois, mas se alguém souber de um jeito.

     

    Tentei substituir os ranges sempre pelo equivalente Range("__:__" & LastRow), mas dá erro de sintaxe.

     

    Podem me ajudar?

  8. Boa noite.

    Estou com uma dificuldade e gostaria de ajuda.

    Tenho uma planilha que uso como um Romaneio, onde digito as Notas fiscais que serão entregues ao motorista.

    Porém, gostaria de utilizar este romaneio como padrão, e sempre após digitar os números de notas, rodar uma macro que copie estes dados e cole eles como valores em outra pasta do excel, porém, sempre abaixo da ultima linha que estiver preenchida, ou seja, na primeira linha vazia, pois haverá numeros de notas fiscais importadas a todo momento, e não posso substituir, pois preciso que a lista de notas digitadas no dia esteja completa no final.

    Espero que possam me ajudar

    Abração

  9. Boa noite à todos.

    Sou novato no fórum e em macros VBA e MUITO NECESSITADO de ajuda...

    Estou trabalhando numa grande empresa e preciso desenvolver um novo modelo de análise de demanda X saldos de itens. MUITO IMPORTANTE PARA MINHA CARREIRA..

    Existe uma planilha na rede que atualiza os saldos em estoque através de um Transfer .dtf, onde na coluna A estão os produtos e na B o saldo;

    Eu elaborei uma planilha onde constam todos os produtos, e criei uma macro que importa os dados desta planilha da rede. Porém, preciso que ao invés de copiar as células e colar, a macro copie e cole somente os valores.

    Segue meu código abaixo:

    Sub ImportarDados()

    Dim wsOrigem As Worksheet

    Dim wsDestino As Worksheet

    Workbooks.Open Filename:="C:\Documents and Settings\ms606184\Desktop\saldoemestoque.xls"

    Set wsOrigem = Workbooks("saldoemestoque.xls").Worksheets("Sheet1")

    Set wsDestino = Workbooks("empresa.xlsm").Worksheets("Sheet2")

    With wsOrigem

    Range("A2:B20000").Copy Destination:=wsDestino.Range("A2:B20000")

    End With

    Workbooks("saldoemestoque.xls").Close SaveChanges:=True

    MsgBox "Importação de Dados Concluída"

    End Sub

    Preciso dela em valores, pois utilizo a seguinte fórmula para jogar os saldos para os produtos, gerando saldo ZERO para os itens que não aparecem na lista:

    =IF(ISNA(VLOOKUP(B6;Sheet2!$A$2:$B$20000;2;FALSE));0;VLOOKUP(B6;Sheet2!$A$2:$B$20000;2;FALSE))

    AGRADEÇO MUITO SE ME AJUDAREM, MESMO..

    Obrigado já..

    Abração

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!