help with this macro

JasonLevan

Registered User.
Local time
Today, 03:33
Joined
Jan 25, 2011
Messages
21
Below is a macro i got from a buddy and it works perfect only i need to add another imput box called item qty the info will record into column b next to what went into column a. and then it will continue on just like before. can anyone help me out

Sub additems()
'
'
Dim NewValue
X = 1
A:
NewValue = InputBox("Enter A Item Number, Enter 3860 If Complete")
If NewValue = "3860" Then GoTo Z:
Range("A" & X).Select
ActiveCell.FormulaR1C1 = NewValue
X = X + 1
GoTo A:
Z:
End Sub
 
surprised that you are testing for a string "3860" when you request a number,3860 .
Also you should declare your variables
Dim X as long
Dim NewValue
declares this as a Variant, which works but?
etc

you do not need to do this
Code:
Range("A" & X).Select
ActiveCell.FormulaR1C1 = NewValue
it cause an interaction with the worksheet which slows the process

Code:
Range("A" & X) = NewValue
is sufficient
Obviously to address col B just change the A to a B

Brian
 
good idea on the 3860, i have one more quirk to add. can i make this macro search out for the first empty cell, say i run it once and then need to go back and run it again to add another number, right now it starts back and overwrites it. Can you write this out for me so all i have to do is copy and paste it, i dont always understand where exactly to add in the lines, i am still learning,


surprised that you are testing for a string "3860" when you request a number,3860 .
Also you should declare your variables
Dim X as long
Dim NewValue
declares this as a Variant, which works but?
etc

you do not need to do this
Code:
Range("A" & X).Select
ActiveCell.FormulaR1C1 = NewValue
it cause an interaction with the worksheet which slows the process

Code:
Range("A" & X) = NewValue
is sufficient
Obviously to address col B just change the A to a B

Brian
 
good idea on the 3860, i have one more quirk to add. can i make this macro search out for the first empty cell, say i run it once and then need to go back and run it again to add another number, right now it starts back and overwrites it. Can you write this out for me so all i have to do is copy and paste it, i dont always understand where exactly to add in the lines, i am still learning,

This may seem a bit blunt but if you want to learn you must think and try things for yourself. I posted code that included finding the lastrow in a previous thread of yours, so it should be easy to use that to find the next row, which is what you want.

Brian
 

Users who are viewing this thread

Back
Top Bottom