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 Super385011
Posts
#22748
Boa Tarde

tentei adaptar este codigo para que seja feito uma copia da linha excluida para a planilha 7 e para a planilha 2 mas funcionou

Private Sub btn_apagar_Click()

Dim plan As Worksheet
Set plan = Sheets("Prazo")

Dim codigo As Integer
Dim produto As String
Dim quantidade As Double
Dim valor As Double
Dim total As Double

codigo = txt_codigo

plan.Select

linha = plan.Range("A:A").Find(codigo).Row
plan.Cells(linha, 1).Select

'Copia as informações que serão excluídas
data = plan.Cells(linha, 1)
produto = plan.Cells(linha, 2)
quantidade = plan.Cells(linha, 3)
valor = plan.Cells(linha, 4)
total = plan.Cells(linha, 5)

Dim resposta As String 'cria a variável resposta
resposta = MsgBox("O registro será excluído. Confirma a exclusão?", vbYesNo) 'cria a mensagem para determinar qual ação será executada

If resposta = vbYes Then ' se a resposta for sim então

'comando para deletar toda a linha
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Delete Shift:=xlUp
ActiveCell.Select

MsgBox ("Registro excluído com sucesso!!!")

End If



'Transfere as informações excluidas para a planilha Excluidos

Plan7.Select 'seleciona a excluidos
Range("A1048576").Select 'seleciona a ultima linha da plan
Selection.End(xlUp).Select 'sobe até o primeira célula com conteúdo
ActiveCell.Offset(1, 0).Select 'desce para célula em branco
linha = ActiveCell.Row 'captura na variável o valor da linha atual

With Plan7
.Cells(linha, 1) = data
.Cells(linha, 2) = produto
.Cells(linha, 3) = quantidade
.Cells(linha, 4) = valor
.Cells(linha, 5) = total
.Cells(linha, 6) = Date
.Cells(linha, 7) = Time
.Cells(linha, 8) = frmLogin.TxtUsuario.Value
.Cells(linha, 9) = nome


Plan2.Select 'seleciona a excluidos
Range("A1048576").Select 'seleciona a ultima linha da plan
Selection.End(xlUp).Select 'sobe até o primeira célula com conteúdo
ActiveCell.Offset(1, 0).Select 'desce para célula em branco
linha = ActiveCell.Row 'captura na variável o valor da linha atual

With Plan2
.Cells(linha, 1) = Date
.Cells(linha, 2) = produto
.Cells(linha, 3) = quantidade
.Cells(linha, 4) = valor
.Cells(linha, 5) = total


End With


'chama o initialize para recarregar as informções atualizadas na StatusBar
Call UserForm_Initialize

end sub
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