Ir ao conteúdo
  • Cadastre-se

AfonsoMira

Membro Pleno
  • Posts

    463
  • Cadastrado em

  • Última visita

posts postados por AfonsoMira

  1. Boas @JorgeSouza ,

     

    Experimente o seguinte código:
     

    Sub soma_se()
    
      'Declara Variavel Livro
      Dim wb As Workbook: Set wb = ThisWorkbook
    
      'Declara Variavel Folha
      Dim ws As Worksheet: Set ws = wb.ActiveSheet
    
      'Vai buscar ultima linha da Coluna A
      Dim ultimaLinha As Long: ultimaLinha = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    
      'Coloca formula na célula D4
      ws.Range("D4").FormulaR1C1 = "=IFERROR(IF(R1C1=R1C7,SUMIFS(C[5],C[3],RC[-2],C[4],RC[-1],C[2],RC[-3])),0)"
    
      'Arrasta da D4 até D e ultima linha
      ws.Range("D4").AutoFill Destination:=ws.Range("D4:D" & ultimaLinha), Type:=xlFillDefault
    
      'Converte fórmula em Valor
      ws.Range("D4:D" & ultimaLinha).Value2 = ws.Range("D4:D" & ultimaLinha).Value2
    
    End Sub

     

    • Obrigado 1
  2. Boas @Jeff_Sandes ,

    Então ao que parece o VBA está a associar o "/" da data como sendo um separador do caminho do ficheiro.

    Experimente desta forma:
     

     Private Sub Salvar_Planilha()
         Dim Data As String
                Data = Format(Date, "mm-yyyy")
                ActiveWorkbook.SaveAs _
                Filename:="C:\Users\Automacao\Desktop\macros\" & Data & ".xlsm"  'Salva planilha com nome de mês e data atual
         Application.DisplayAlerts = False 'Desativa Pop-Up de pergunta se deseja salvar ou não
         Application.Quit 'Fecha Excel
     End Sub

     

    Ps. Não testei aqui

  3. Boas @Matheus Orchulhak ,

     

    Experimente algo deste género:
     

    Dim caminho As String
    Dim este As Workbook, outro As Workbook
    
    Application.DisplayAlerts = False
    caminho = ("C:\Users\mathe\OneDrive - Fugro\DRILLING\demandas\220718\1.xlsx")
    
    Set outro = ActiveWorkbook
    Set este = Workbooks.Open(caminho)
    
    outro.Sheets(2).Range("A2").Copy
    este.Sheets(1).Range("B28").PasteSpecial
    outro.Sheets(2).Range("B2:F2").Copy
    este.Sheets(1).Range("I29:I33").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True

     

  4. Boas @Victorhugoc ,
    Experimente trocar:

    Word.SaveAs xFolderPath & "\" & xFileName & ".PDF"   (Nessa parte ta dando erro)

     

    Por:

    ActiveDocument.ExportAsFixedFormat OutputFileName:= _
                xFolderPath & "\" & xFileName & ".pdf", _
                ExportFormat:=wdExportFormatPDF, _
                OpenAfterExport:=False, _
                OptimizeFor:=wdExportOptimizeForPrint, _
                Range:=wdExportAllDocument, _
                IncludeDocProps:=True, _
                CreateBookmarks:=wdExportCreateWordBookmarks, _
                BitmapMissingFonts:=True
  5. Boas @lucas.sns ,
     

    Experimente da seguinte forma:
    Crie um novo módulo e cole estas macros lá:
     

    Sub somar()
        Dim s As Shape, linha As Long, sname As String
        Dim valor, stock_anterior, stock_atual As Long
        
        sname = Application.Caller
        Set s = ActiveSheet.Shapes(sname)
        linha = s.TopLeftCell.Row
        
        valor = Range("B" & linha).Value
        
        stock_anterior = Range("I" & linha).Value
        
        stock_atual = stock_anterior + valor
        
        Range("B" & linha).Value = 0
        Range("I" & linha).Value = stock_atual
    
    End Sub

     

    Sub subtrair()
    
        Dim s As Shape, linha As Long, sname As String
        Dim valor, stock_anterior, stock_atual As Long
        
        sname = Application.Caller
        Set s = ActiveSheet.Shapes(sname)
        linha = s.TopLeftCell.Row
        
        valor = Range("B" & linha).Value
        
        stock_anterior = Range("I" & linha).Value
        
        stock_atual = stock_anterior - valor
        
        Range("B" & linha).Value = 0
        Range("I" & linha).Value = stock_atual
    
    End Sub

     

    Depois para cada botão de somar atribua a macro "Somar" e para cada botão de subtrair a macro "subtrair".

    Ele vai verificar qual a linha em que está o botão que chamou a macro, e vai proceder a alteração do stock.

    Espero ter ajudado. 🙂

    • Curtir 1
  6. Boas, @Jeff_Sandes

    Em relação ao código veja se assim funciona:
     

    Sub MACRO()
    	Range("A1").Select
    	Selection.Copy
    	Range("B1").Select
    	Selection.PasteSpecial Paste:= xlpastevalues, operation:= none, SkipBlanks _
    	:= False, Transpose:= False
    End Sub

     

    Quanto ao seguinte:

    27 minutos atrás, Jeff_Sandes disse:
    Private Sub HORIMETRO()
    Application.OnTime TimeValue("12:00:00"), procedure = "MACRO", schedule = true
    End sub

    Experimente alterar o nome da macro. Exemplo em vez de "MACRO" coloque "copiar_colar" e veja se resulta.

     

    Cumps,

    Afonso Mira

    • Amei 1
  7. @Leandro Lamin Boas,

     

    Experimente assim:

    Sub Excel_to_WhatsApp()
    Dim r As Long
    Dim Linha As Integer
    Dim strip As String
    Dim Numero_Telefone As String
    Dim Mensagem As String
    Dim Enviar As String
    Dim Object As Object
    
    r = Range("A" & Rows.Count).End(xlUp).Row
    For Linha = 2 To r
    
    Numero_Telefone = Planilha1.Cells(Linha, 1).Value
    Mensagem = Planilha1.Cells(Linha, 2).Value
    
    Planilha1.Cells(Linha, 2).copy
    
    Enviar = "whatsapp://send?phone=" & Numero_Telefone & "&text=" & Mensagem
    
    Set Object = CreateObject("InternetExplorer.Application")
    
    Object.navigate Enviar
    
    Application.Wait (Now + TimeValue("00:00:05"))
    Call SendKeys("^v")
    
    Application.Wait (Now + TimeValue("00:00:05"))
    
    Call SendKeys("{Enter}", True)
    
    'Application.Wait Now() + TimeSerial(0, 0, 5)
    'SendKeys "~"
    
    Next Linha
    End Sub

    PS. Não testei aqui

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...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!