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
#59072
Bom dia a todos,
Sou Marlon, novo no Forum,

Tenho uma planilha com a seguinte macro, gostaria de incluir a captura de mais uma coluna.

Quando lanço entrada ou saída de estoque e clico em atualizar ele exporta para planilha de histórico as informações do Produto, Data, Quantidade (entrada ou Saída), quero incluir nessa exportação a última coluna (Origem se for entrada ou Destino se for saída).

Como consigo isso?

Abaixo a Macro e anexo o arquivo.

Sub AtualizarEstoqueEntrada()

Dim i As Integer
Dim j As Integer
Dim o As Integer
Dim Tabela As Variant
Dim n As Integer
Dim DATA As Date
Dim vparcela As Double
Dim k As Integer





'Lê o tamanho da compra
i = 2
While Planilha2.Cells(i, 1) <> ""
i = i + 1
Wend


If Planilha2.Cells(i - 1, 3) = "" Then
MsgBox " Digite todos os dados", vbCritical, " Atenção."


End If


If Planilha2.Cells(i - 1, 3) <> "" Then








'Seleciona dados da compra
Set Tabela = Range(Cells(3, 1), Cells(i - 1, 6))

'Cola dados da compra no Banco de Dados
n = TextBox1
j = 1



vparcela = WorksheetFunction.Sum(Range(Tabela(1, 6), Tabela(i - 2, 6)))



While Planilha4.Cells(j, 1) <> ""
j = j + 1
Wend


Planilha4.Cells(j, 6) = vparcela
j = j + 1





o = 1

j = 2

While Planilha4.Cells(j, 2) <> ""
j = j + 1
Wend

For m = j To (j + i - 3)
Planilha4.Cells(m, 4) = "Entrada"

For S = 1 To 3
Planilha4.Cells(m, S) = Tabela(o, S)
Next S
o = o + 1
Next m


'Apaga dados da tabela
Planilha2.Select

On Error Resume Next
Range("A3:E50").SpecialCells(xlCellTypeConstants).ClearContents
On Error GoTo 0

MsgBox "Estoque atualizado!", vbOKOnly, "Concluído"
End If


End Sub

Sub AtualizarEstoqueSaida()
Dim i As Integer
Dim j As Integer
Dim o As Integer
Dim Tabela As Variant
Dim n As Integer
Dim DATA As Date
Dim vparcela As Double





'Lê o tamanho da compra
i = 2
While Planilha3.Cells(i, 1) <> ""
i = i + 1
Wend




If Planilha3.Cells(i - 1, 3) = "" Then
MsgBox " Digite todos os dados", vbCritical, " Atenção."

End If


If Planilha3.Cells(i - 1, 3) <> "" Then

'Seleciona dados da compra
Set Tabela = Range(Cells(3, 1), Cells(i - 1, 6))

'Cola dados da compra no Banco de Dados
n = TextBox1
j = 1



vparcela = WorksheetFunction.Sum(Range(Tabela(1, 6), Tabela(i - 2, 6)))



While Planilha4.Cells(j, 1) <> ""
j = j + 1
Wend




j = j + 1





o = 1

j = 2

While Planilha4.Cells(j, 2) <> ""
j = j + 1
Wend

For m = j To (j + i - 3)
Planilha4.Cells(m, 4) = "Saída"

For S = 1 To 3
Planilha4.Cells(m, S) = Tabela(o, S)
Next S
o = o + 1
Next m


'Apaga dados da tabela
Planilha3.Select

On Error Resume Next
Range("A3:E50").SpecialCells(xlCellTypeConstants).ClearContents
On Error GoTo 0

MsgBox "Estoque atualizado!", vbOKOnly, "Concuído"


End If



End Sub
Você não está autorizado a ver ou baixar esse anexo.
#59155
Boas veja se resolve o problema. :D
Você não está autorizado a ver ou baixar esse anexo.
MarlonGripp agradeceu por isso
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