I am trying to write a Macro that will autofill another spreadsheet based on the weight of product A that I have.
For example, I have 6000 lbs of Product A with order number 456ABC.
I want to write code that will look at the weight (6000) and knowing that each bag weighs 100 pounds, autofill 60 rows with order number 456ABC.
Raw Data
A B C
1 456ABC 6000
2
3
"Run Macro"
Finished spreadsheet
A B C
1 456ABC
2 456ABC
3 456ABC
.
.
.
.
60 456ABC
I'm thinking I want to use a Do While Loop but I'm having trouble with the If statement, specifically with how to have a calculated value as your less than.
I have pasted the code I have so far below:
Sub Transcribe_Lot_Numbers_Do_While()
Dim i As Integer
Dim a As Integer
i = 0
a = 1
Do While i < 5000
If a < Range("B1"+i)/400
Cells(i + 1, 6).Value = Range("A1" + i)
a = a + 1
Next a
i = i + 1
Next i
End Sub
Thank you for your help!
For example, I have 6000 lbs of Product A with order number 456ABC.
I want to write code that will look at the weight (6000) and knowing that each bag weighs 100 pounds, autofill 60 rows with order number 456ABC.
Raw Data
A B C
1 456ABC 6000
2
3
"Run Macro"
Finished spreadsheet
A B C
1 456ABC
2 456ABC
3 456ABC
.
.
.
.
60 456ABC
I'm thinking I want to use a Do While Loop but I'm having trouble with the If statement, specifically with how to have a calculated value as your less than.
I have pasted the code I have so far below:
Sub Transcribe_Lot_Numbers_Do_While()
Dim i As Integer
Dim a As Integer
i = 0
a = 1
Do While i < 5000
If a < Range("B1"+i)/400
Cells(i + 1, 6).Value = Range("A1" + i)
a = a + 1
Next a
i = i + 1
Next i
End Sub
Thank you for your help!