VBA Form not working properly

awillians26

New Member
Joined
Aug 25, 2022
Messages
2
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi All,

I created a very basic form on VBA. However when I open the file for the first time it works perfectly, but If I opened again it doesn't open the form. What Am I missing here?

View attachment 84356


This is my code - If there's a way to clean up to make better please advise

VBA Code:
Private Sub CommandButton1_Click()

End Sub

Private Sub CancelButton_Click()
On Error GoTo ErrorHandler
    Unload Me
    Exit Sub
ErrorHandler:
    MsgBox "An error occurred: " & Err.Description

End Sub

Private Sub Label1_Click()

End Sub

Private Sub Label3_Click()

End Sub

Private Sub Label4_Click()

End Sub

Private Sub Label5_Click()

End Sub




Private Sub Image1_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As MSForms.fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)

End Sub

Private Sub UserForm_Initialize()

    dHeight = Me.Height

End Sub



Private Sub Submit_Click()
 
  Dim LR As Long

   LR = Cells(Rows.Count, 1).End(xlUp).Row + 1

   Cells(LR, 3).Value = PartNumber.Value
   Cells(LR, 4).Value = Vendor.Value
   Cells(LR, 5).Value = Quantity.Value
   Cells(LR, 6).Value = EmpName.Value
   Cells(LR, 7).Value = Comments.Value
 
   EmpName.Value = ""
   Vendor.Value = ""
   PartNumber = ""
   Quantity.Value = ""
   Comments.Value = ""

End Sub

This is the code I'm using for the WorkBook

VBA Code:
Private Sub Workbook_Open()
Application.Visible = False
Purchasing.Show

End Sub
 
Last edited by a moderator:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,215,043
Messages
6,122,816
Members
449,095
Latest member
m_smith_solihull

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