Multiple Userform One works the other not

PuntingJawa

Board Regular
Joined
Feb 25, 2021
Messages
158
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I am having trouble with one of my userforms. I have set up a simplistic input for Receiving and have a nearly identical one for shipping. The receiving works fine (See first) but shipping will not work on it's page. Is there something I must change when using multiple userforms in the same workbook?

Working (Receiving)
VBA Code:
Private Sub TextBox1_Change()

End Sub

Private Sub TextBox10_Change()
    TextBox10.Text = UCase(TextBox10.Text)
End Sub

Private Sub TextBox11_Change()
    TextBox11.Text = UCase(TextBox11.Text)
End Sub

Private Sub TextBox2_Change()
    TextBox2.Text = UCase(TextBox2.Text)
End Sub

Private Sub TextBox3_Change()
    TextBox3.Text = UCase(TextBox3.Text)
End Sub

Private Sub TextBox4_Change()
    TextBox4.Text = UCase(TextBox4.Text)
End Sub

Private Sub TextBox5_Change()
    TextBox5.Text = UCase(TextBox5.Text)
End Sub

Private Sub TextBox6_Change()
    TextBox6.Text = UCase(TextBox6.Text)
End Sub

Private Sub TextBox7_Change()
    TextBox7.Text = UCase(TextBox7.Text)
End Sub

Private Sub TextBox8_Change()
    TextBox8.Text = UCase(TextBox8.Text)
End Sub

Private Sub TextBox9_Change()
    TextBox9.Text = UCase(TextBox9.Text)
End Sub

Private Sub UserForm_Activate()

TextBox1.Text = Format(Now(), "MM/DD/YY")


End Sub
Private Sub CommandButton1_Click()

erow = Sheets("Corp Receiving").Range("a" & Rows.Count).End(xlUp).Row
    Range("A" & erow + 1) = TextBox1.Value
    Range("B" & erow + 1) = TextBox2.Value
    Range("C" & erow + 1) = TextBox3.Value
    Range("D" & erow + 1) = TextBox4.Value
    Range("E" & erow + 1) = TextBox5.Value
    Range("F" & erow + 1) = TextBox6.Value
    Range("G" & erow + 1) = TextBox7.Value
    Range("I" & erow + 1) = "PS " & TextBox8.Value
    Range("J" & erow + 1) = "PO " & TextBox9.Value
    Range("K" & erow + 1) = TextBox10.Value
    Range("L" & erow + 1) = TextBox11.Value

End Sub

Not working (Shipping)
VBA Code:
Private Sub TextBoxs1_Change() 'Date box

End Sub

Private Sub TextBoxs10_Change()
    TextBoxs10.Text = UCase(TextBoxs10.Text) 'Our RMA box
End Sub

Private Sub TextBoxs11_Change()
    TextBoxs11.Text = UCase(TextBoxs11.Text) 'Customer RMA box
End Sub

Private Sub TextBoxs2_Change()
    TextBoxs2.Text = UCase(TextBoxs2.Text) 'Customer Name box
End Sub

Private Sub TextBoxs3_Change()
    TextBoxs3.Text = UCase(TextBoxs3.Text) 'Project Code box
End Sub

Private Sub TextBoxs4_Change()
    TextBoxs4.Text = UCase(TextBoxs4.Text) 'Packing # or Item #'s and QTYs box
End Sub

Private Sub TextBoxs5_Change()
    TextBoxs5.Text = UCase(TextBoxs5.Text) 'Carrier company box
End Sub

Private Sub TextBoxs6_Change()
    TextBoxs6.Text = UCase(TextBoxs6.Text) 'Tracking # box
End Sub

Private Sub TextBoxs7_Change()
    TextBoxs7.Text = UCase(TextBoxs7.Text) 'QTY of boxes/pallet/crate box
End Sub

Private Sub TextBoxs8_Change()
    TextBoxs8.Text = UCase(TextBoxs8.Text) 'Weight in LBS box
End Sub

Private Sub TextBoxs9_Change()
    TextBoxs9.Text = UCase(TextBoxs9.Text) 'NCR # box
End Sub

Private Sub UserForm_Activate()

TextBoxs1.Text = Format(Now(), "MM/DD/YY") 'Date format to today without resetting manually


End Sub
Private Sub CommandButton2_Click()

erow = Sheets("Corp Shipping").Range("a" & Rows.Count).End(xlUp).Row
    Range("A" & erow + 1) = TextBoxs1.Value 'Date
    Range("B" & erow + 1) = TextBoxs2.Value 'Customer
    Range("C" & erow + 1) = TextBoxs3.Value 'Project
    Range("D" & erow + 1) = TextBoxs4.Value 'Items #'s or Packing slip #
    Range("E" & erow + 1) = TextBoxs5.Value 'Carrier
    Range("F" & erow + 1) = TextBoxs6.Value 'Tracking #
    Range("G" & erow + 1) = TextBoxs7.Value '# of boxes
    Range("H" & erow + 1) = TextBoxs8.Value & "LBS" 'Weight
    Range("I" & erow + 1) = "NCR " & TextBoxs9.Value 'NCR # Customer and Ours
    Range("J" & erow + 1) = "RMA " & TextBoxs10.Value 'Our RMA #
    Range("K" & erow + 1) = TextBoxs11.Value 'Customer RMA #
   
    TextBoxs2.Value = "" 'Removes after submit
    TextBoxs3.Value = "" 'Removes after submit
    TextBoxs4.Value = "" 'Removes after submit
    TextBoxs5.Value = "" 'Removes after submit
    TextBoxs6.Value = "" 'Removes after submit
    TextBoxs7.Value = "" 'Removes after submit
    TextBoxs8.Value = "" 'Removes after submit
    TextBoxs9.Value = "" 'Removes after submit
    TextBoxs10.Value = "" 'Removes after submit
    TextBoxs11.Value = "" 'Removes after submit

End Sub
 
Are the textboxes cleared?

I'm wondering if Private Sub CommandButton2_Click() actually runs. Set a breakpoint on the first line after Private Sub, and step through the population process. Check the variables and values.
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Are the textboxes cleared?

I'm wondering if Private Sub CommandButton2_Click() actually runs. Set a breakpoint on the first line after Private Sub, and step through the population process. Check the variables and values.
I set the "Clear" to a button. The clear function works. I just did the debugging. I did the same to Receiving and they are both identical.

This is what I am looking at (button wise)
Receiving (Submitting to sheet3 "Receiving" as intending)
VBA Code:
Private Sub ReceivingSubmit_Click() 'Command button submit

erow = Sheets("Receiving").Range("a" & Rows.Count).End(xlUp).Row 'Submit on next open "A" row
    Range("A" & erow + 1) = RecDate.Value 'Date
    Range("B" & erow + 1) = RecSupplier.Value 'Supplier
    Range("C" & erow + 1) = RecProject.Value 'Project #
    Range("D" & erow + 1) = RecDescription.Value 'Decription
    Range("E" & erow + 1) = RecPartNumber.Value 'Part #
    Range("F" & erow + 1) = RecSlipQTY.Value 'Packing slip QTY
    Range("G" & erow + 1) = RecCountQTY.Value 'Actual count QTY
    Range("I" & erow + 1) = "PS " & RecPackNumber.Value 'Pack Slip #
    Range("J" & erow + 1) = "PO " & RecPO.Value 'Purchase Order #
    Range("K" & erow + 1) = RecNCR.Value 'NCR #
    Range("L" & erow + 1) = RecRMA.Value 'RMA #

Then Shipping (Not submitting to sheet1 "Shipping")
VBA Code:
Private Sub ShippingSubmit_Click() 'Command button Submit

erow = Sheets("Shipping").Range("a" & Rows.Count).End(xlUp).Row 'Submit on next open "A" row
    Range("A" & erow + 1) = ShipDate.Value 'Date
    Range("B" & erow + 1) = ShipCustomer.Value 'Customer
    Range("C" & erow + 1) = ShipProject.Value 'Project
    Range("D" & erow + 1) = ShipItems.Value 'Items #'s or Packing slip #
    Range("E" & erow + 1) = ShipCarrier.Value 'Carrier
    Range("F" & erow + 1) = ShipTracking.Value 'Tracking #
    Range("G" & erow + 1) = ShipPackQTY.Value '# of boxes
    Range("H" & erow + 1) = ShipWeight.Value & "LBS" 'Weight
    Range("I" & erow + 1) = "NCR " & ShipNCR.Value 'NCR # Customer and Ours
    Range("J" & erow + 1) = "RMA " & ShipRMA.Value 'Our RMA #
    Range("K" & erow + 1) = ShipCustomerRMA.Value 'Customer RMA #
End Sub
 
Upvote 0
I've modified the procedure. A few comments on coding practice:

  • Use Worksheets() not Sheets()
  • Add worksheet reference to ranges: Worksheets("Shipping").Range(whatever) not Range(whatever)
  • Even better for performance would be to put the values into an array, then write to the worksheet in one step, but let's see if clicking the button stops execution at the breakpoint.

Set a breakpoint where indicated, then run the form and click the submit button. Step through with the F8 key. Is erow what you expect?

VBA Code:
Private Sub ShippingSubmit_Click() 'Command button Submit
    ' SET BREAKPOINT ON THIS LINE:
    erow = Worksheets("Shipping").Range("a" & Rows.Count).End(xlUp).Row 'Submit on next open "A" row
    With Worksheets("Shipping").Range("A" & erow + 1)
        .Value = ShipDate.Value 'Date
        .Offset(, 1).Value = ShipCustomer.Value 'Customer
        .Offset(, 2).Value = ShipProject.Value 'Project
        .Offset(, 3).Value = ShipItems.Value 'Items #'s or Packing slip #
        .Offset(, 4).Value = ShipCarrier.Value 'Carrier
        .Offset(, 5).Value = ShipTracking.Value 'Tracking #
        .Offset(, 6).Value = ShipPackQTY.Value '# of boxes
        .Offset(, 7).Value = ShipWeight.Value & "LBS" 'Weight
        .Offset(, 8).Value = "NCR " & ShipNCR.Value 'NCR # Customer and Ours
        .Offset(, 9).Value = "RMA " & ShipRMA.Value 'Our RMA #
        .Offset(, 10).Value = ShipCustomerRMA.Value 'Customer RMA #
    End With
End Sub
 
Last edited:
Upvote 0
Solution
I had to set the break point on the erow line as I got an error saying I could not set the break point on the "empty" line that is quoted out.
When I followed your instruction (F8 then hit submit) this is the error that comes up and highlighted at '.range'
1652886447226.png
 
Upvote 0
Copy and Paste mistake, my bad. That line should read:

VBA Code:
With Worksheets("Shipping").Range("A" & erow + 1)

I've corrected it in my earlier post, too.
 
Upvote 0
Copy and Paste mistake, my bad. That line should read:

VBA Code:
With Worksheets("Shipping").Range("A" & erow + 1)

I've corrected it in my earlier post, too.
It went through Debugging with no errors that time. Still no submission to the worksheet though.
If there's a different formatting or my code can be cleaned up I'm more than happy to try anything to get this to work. I'm just finding it odd that it works for one of my VBA UserForms but not an almost identical (other than names) of the same formatting.
 
Upvote 0
Sorry, Dave. The "shipping" userform is doing the same as before except this time it doesn't work the "receiving" log like the other did. I know I am missing something minor. I was hoping to salvage what I had done but may need to start over and simply redo the entire thing. This is just a quality of life for a manual log of my personal use as a backup.

Curious you clearly have something going on
See you are getting plenty of 1st class assistance but would help if could place copy of your workbook with dummy data on a file sharing site like dropbox & provide a link to it.

Dave
 
Upvote 0
What's the value of erow? Is it what you think it should be, or is it off somewhere 100,000 rows below the apparent end of data?
 
Upvote 0
What's the value of erow? Is it what you think it should be, or is it off somewhere 100,000 rows below the apparent end of data?
I'm feeling a little sheepish right now and knew it had to be something simple.
I should have noticed that the bar on the right side was really large and trailed to the bottom. It seemed that whomever was maintaining this log thought it funny to go all the to the bottom right of the sheet and place a period... I am so sorry for all the time I used on this. Thank you all so much for the help.
Curious you clearly have something going on
See you are getting plenty of 1st class assistance but would help if could place copy of your workbook with dummy data on a file sharing site like dropbox & provide a link to it.

Dave
Truthfully, if it weren't for this suggestion and me clearing information to get a book ready and testing one last time I never would have noticed. Thank you as well.
 
Upvote 0
No worries. These are the steps you have to take to debug something like this. Next time you'll do it on your own in less time.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top