ColdSpirit
New Member
- Joined
- Sep 30, 2022
- Messages
- 18
- Office Version
- 2010
- Platform
- Windows
Hello all!
I am new to programming in general, and I know very little of Excel VBA / macros.
I need help inserting a sequential number from A6 to a dynamic number based on a previous number.
Example: I have an initial number(B1) and a final number(B2), and finally, the amount between the initial number and the final number, which I call the total (including)(B3).
B2-B1=B3
and I want to insert a sequential number on A6 to the final number with increments of +1 until It reaches the final number.
A6 should have the initial number too.
At the moment the code I have is this:
Many thanks in advance.
I am new to programming in general, and I know very little of Excel VBA / macros.
I need help inserting a sequential number from A6 to a dynamic number based on a previous number.
Example: I have an initial number(B1) and a final number(B2), and finally, the amount between the initial number and the final number, which I call the total (including)(B3).
B2-B1=B3
and I want to insert a sequential number on A6 to the final number with increments of +1 until It reaches the final number.
A6 should have the initial number too.
At the moment the code I have is this:
VBA Code:
Private Sub CommandButton1_Click()
Dim ni As Range 'determinar o numero inicial
Dim nf As Range 'determinar o numero final
Dim ws As Worksheet 'determinar o valor "ws" como worksheet
Set ws = ThisWorkbook.Sheets("047") 'associar "ws" à folha "047"
Set ni = Range("B1") 'associar ni = Célula J1
Set nf = Range("B2") 'associar fi = Célula J2
Set Total = Range("B3") 'associar total = Célula J3
Columns(1).ClearContents 'limpar a coluna A(1)
ni = _
InputBox(Prompt:="Inserir Numero Inicial") 'ni -inserção da numeração inicial (+ criação da inputbox)
nf = _
InputBox(Prompt:="Inserir Numero Final") 'fi -inserção da numeração final (+ criação da inputbox)
MsgBox "Numeração AWB inserida com sucesso" 'mensagem após inserção de numeração da awb
End Sub
Many thanks in advance.