Making A number AdvanceWith Each Cycle

  • Thread starter Thread starter Minitman
  • Start date Start date
M

Minitman

Greetings,

I nave a UserForm that has an item number that is supposed to advance
with each new item. It doesn't!!!

Maybe one of you could look at my code and let me know what I did
wrong.

Private Sub UserForm_Initialize()

If Range("dNum").Value = "" Then
Range("dNum").Value = 1
TB2.Value = Range("dNum").Value
Range("dNum").Value = Range("dNum").Value + 1
Else
TB2.Value = Range("dNum").Value
Range("dNum").Value = TB2.Value + 1
TB2.TabStop = False
End If

End Sub

dNum is a place holder for this number. TB2 is the TextBox on the
UserForm for the number which is pasted down when the user clicks on
the Save button. The Save button also closes the UserForm and then
restarts it - Cycling.

Any ideas on what is wrong with this code? Or ideas on what to
replace it with?

Any help would be most appreciated.

TIA

-Minitman
 
Hi Minitman,

I just try your code every time the userform load it adds +1 to the dNum
values.

Your code was initialize the userform should be Userform_Activate.

Your save button should have a different code to activate the new value of
your dNum range.

It works okey using Userform_Activate. If you have time why not send to me
the excel file and I can fix it for you. Hope this helps.
 
Hey Mel,

I found the error. It was in the area that cleared out the default
values of several of the TextBoxes. I had forgotten to remove the
reference to TB2, So every time I put a number into TB2, I was
immediately erasing it - Kind of dumb really!!!

Thanks for the reply.

-Minitman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top