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.
Por GermaHeidel
#51940
Olá pessoal! Estou precisando de uma ajuda para uma planilha que uso aqui na empresa. Esse codigo roda normal, só que me surgiu outra variavel, preciso de mais 3 variaveis. Exemplo: Quando eu digitar no lugar de ok, 1 vai para planilha PCP 1, Quando eu digitar 2, vai para planilha PCP 2, quando digitar 3 vai para planilha PCP 3 e assim por diante, tentei copiar e colar o codigo adicionando as outras variaveis, mas não deu certo, imagino que tenha que criar um loop, mas não consegui. Por favor poderiam me ajudar. Segue o codigo que uso atualmente:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 9 Then Exit Sub
If Target.Value <> "ok" Then Exit Sub
Dim LR As Long
With Sheets("PCP")
LR = .Cells(Rows.Count, 1).End(xlUp).Row
.Cells(LR + 1, 1).Resize(, 8).Value = Cells(Target.Row, 1).Resize(, 8).Value
End With
'Rows(Target.Row).Delete
End Sub
Por osvaldomp
#51944
Segue uma sugestão.
Código: Selecionar todos
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim LR As Long
  If Target.Column <> 9 Then Exit Sub
   With Sheets("PCP " & Target.Value)
   LR = .Cells(Rows.Count, 1).End(xlUp).Row
   .Cells(LR + 1, 1).Resize(, 8).Value = Cells(Target.Row, 1).Resize(, 8).Value
   End With
   'Rows(Target.Row).Delete
End Sub
obs. renomeie a planilha PCP como PCP 0 e em lugar de ok digite 0
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