Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
  • Avatar do usuário
Avatar do usuário
Por Moura
Avatar
#11021
Boa tarde,

Tenho uma planilha com um interface de registros, e outra aba com uma base de dados. Na aba da base de dados, tenho uma linha (A2) que puxa automaticamente as informações da interface de registros.

Quero fazer o seguinte: sempre que eu atualizar uma informação de um registro, quero buscar ele na base de dados, e substituir a linha desse registro pela linha que puxa automaticamente (A2).

Até agora tenho a seguinte macro:
Código: Selecionar todos
'
' Atualizar Macro
'

'
   Dim linha As Variant
   
   Dim pesquisa As String

       pesquisa = Range("E8")

       If pesquisa = "" Then Exit Sub
       
       Sheets("Base de Dados").Select
       Rows("2:2").Select
       Selection.Copy

       Set linha = .Find(what:=pesquisa, LookIn:=xIValues)
       If Not linha Is Nothing Then
           celula = linha.Address
               
               Do
               plan.Select
               linha.Select
                               
       ActiveSheet.Paste
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       
       Loop While Not linha Is Nothing And linha.Address <> celula
       
       End If
                           
   Sheets("Interface").Select
   MsgBox "Dados atualizados com sucesso."

   
End Sub

Mas essa macro não está executando. Alguém pode me ajudar a identificar o erro ou indicar uma solução melhor?
#11053
Bom dia!!

Seria isso?
Código: Selecionar todos
Sub AleVBA_2192()
Dim r As Range, rSource As Range
Dim lngLastRow As Long
lngLastRow = Range("A" & Rows.Count).End(xlUp).Row
Set rSource = Range("A4:G" & lngLastRow)
rSource.AutoFilter Field:=1, Criteria1:=Range("A2").Value
    For i = 5 To lngLastRow
      If Not Intersect(Range("A" & i), Range("A2:G" & lngLastRow).SpecialCells(xlCellTypeVisible)) Is Nothing Then
        Range("A" & i).Value = Range("A2").Value
        Range("B" & i).Value = Range("B2").Value
        Range("C" & i).Value = Range("C2").Value
        Range("D" & i).Value = Range("D2").Value
        Range("E" & i).Value = Range("E2").Value
        Range("F" & i).Value = Range("F2").Value
        Range("G" & i).Value = Range("G2").Value
      End If
    Next
rSource.AutoFilter
End Sub
Att
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord