Notifications
Clear all

Código VBA

3 Posts
3 Usuários
0 Reactions
1,111 Visualizações
(@bicudo69)
Posts: 6
Active Member
Topic starter
 

Boa tarde estou aproveitando um formulário antigo e ajustando para as necessidades do trabalho e estou com uma duvida na via q estou utilizando. Ao cadastrar os dados na planilha ele salva alguns e outros não tem como alguém dar uma olhada e ver o pode estar de errado. Segue o código:

Sub Cadastro()

' Cadastro Macro

Application.ScreenUpdating = False


    Sheets("Banco de Dados").Select

    Rows("1:3").Select

    Selection.EntireRow.Hidden = False

    Range("A2:W2").Select

    Selection.Copy

    ActiveWindow.ScrollColumn = 20

    ActiveWindow.ScrollColumn = 18

    ActiveWindow.ScrollColumn = 16

    ActiveWindow.ScrollColumn = 15

    ActiveWindow.ScrollColumn = 14

    ActiveWindow.ScrollColumn = 13

    ActiveWindow.ScrollColumn = 12

    ActiveWindow.ScrollColumn = 10

    ActiveWindow.ScrollColumn = 8

    ActiveWindow.ScrollColumn = 6

    ActiveWindow.ScrollColumn = 4

    ActiveWindow.ScrollColumn = 1

    Rows("3:3").Select

    Selection.Insert Shift:=xlDown

    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _

        :=False, Transpose:=False

    Rows("2:2").Select

    Selection.EntireRow.Hidden = True

    Sheets("Cadastrar").Select

    Range("F3:P3").Select

    Application.CutCopyMode = False

    Selection.ClearContents

    Range("R3").Select

    Selection.ClearContents

    Range("T3").Select

    Selection.ClearContents

    Range("F5:J5").Select

    Selection.ClearContents

    Range("L5:N5").Select

    Selection.ClearContents

    Range("P5:T5").Select

    Selection.ClearContents

    Range("F8").Select

    Selection.ClearContents

    Range("H8").Select

    Selection.ClearContents

    Range("J8").Select

    Selection.ClearContents

    Range("L8:N8").Select

    Selection.ClearContents

    Range("P8:R8").Select

    Selection.ClearContents

    Range("T8").Select

    Selection.ClearContents

    Range("A10:H10").Select

    Selection.ClearContents

    Range("J10:L10").Select

    Selection.ClearContents

    Range("N10:P10").Select

    Selection.ClearContents

    Range("R10").Select

    Selection.ClearContents

    Range("T10").Select

    Selection.ClearContents

    Range("R12:T12").Select

    Selection.ClearContents

    Range("A14:B14").Select

    Selection.ClearContents

    Range("D14").Select

    Selection.ClearContents

    Range("F14:H14").Select

    Selection.ClearContents

    Range("J14").Select

    Selection.ClearContents

    Range("L14").Select

    Selection.ClearContents

    Range("N14:P14").Select

    Selection.ClearContents

    Range("R14:T14").Select

    Selection.ClearContents

    Range("A16:B16").Select

    Selection.ClearContents

    Range("D16").Select

    Selection.ClearContents

    Range("F16:H16").Select

    Selection.ClearContents

    Range("J16").Select

    Selection.ClearContents

    Range("L16").Select

    Selection.ClearContents

    Range("N16:P16").Select

    Selection.ClearContents

    Range("R16:T16").Select

    Selection.ClearContents

    Range("A18:B18").Select

    Selection.ClearContents

    Range("D18").Select

    Selection.ClearContents

    Range("F18:H18").Select

    Selection.ClearContents

    Range("J18").Select

    Selection.ClearContents

    Range("L18").Select

    Selection.ClearContents

    Range("N18:P18").Select

    Selection.ClearContents

    Range("R18:T18").Select

    Selection.ClearContents

    Range("A21:B21").Select

    Selection.ClearContents

    Range("D21:F21").Select

    Selection.ClearContents

    Range("H21:J21").Select

    Selection.ClearContents

    Range("L21:N21").Select

    Selection.ClearContents

    Range("P21:T21").Select

    Selection.ClearContents

    Range("A23:J23").Select

    Selection.ClearContents

    Range("L23:T23").Select

    Selection.ClearContents

    Range("A1:D8").Select

    

    MsgBox "Cadastro realizado com sucesso"

    

    Application.ScreenUpdating = True

End Sub
 
Postado : 31/07/2017 1:08 pm
brunoxro
(@brunoxro)
Posts: 698
Honorable Member
 

Boa tarde,

Quais ele não salva?

att,

 
Postado : 31/07/2017 3:14 pm
(@fulanoetal)
Posts: 3
New Member
 

Ola, verificando a planilha e o código observei que o que ocorre é que existe um vínculo direto entre a planilha "Banco de Dados" e "Cadastro" NA LINHA 2 - o código em questão está apenas colando como valor estes vínculos linha 3 e movendo uma linha os valores já cadastrado.

Recupere os vínculos perdidos e o problema se resolve.

 
Postado : 01/08/2017 1:40 pm