VBA Choose File Open on Macro Run

univegabw

New Member
Joined
Mar 26, 2020
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hello all,

I'm creating a training database file in excel. I've got a Create Training Record button and when I click it opens a user form. When I enter data and hit "Add Record" it opens up an explorer window to choose a file from my drives. If I hit cancel it then will allow the information I typed to be added to the table. Any idea why it is launching a open file? I'll clean up co Here is all the code I have:
Lives in Forms:
Private Sub cmdAddRecord_Click()

eRow = Worksheets("TrainingDataBase").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

Cells(eRow, 1) = EmpID.Value
Cells(eRow, 2) = TrnType.Value
Cells(eRow, 3) = SubType.Value
Cells(eRow, 4) = DateComp.Value

End Sub

Private Sub cmdExit_Click()

Dim iExit As VbMsgBoxResult

iExit = MsgBox("Confirm if you want to exit", vbQuestion + vbYesNo, "Data Entry Form")

If iExit = vbYes Then
Unload Me
End If

End Sub

Private Sub cmdReset_Click()

EmpID.Text = ""
DateComp.Text = ""
TrnType.Text = ""
SubType.Text = ""

End Sub


Lives in Module 1
Sub CreateTrainingRecord()

'Start Userform Centered inside Excel Screen (for dual monitors)
User_Form.StartUpPosition = 0
User_Form.Left = Application.Left + (0.5 * Application.Width) - (0.5 * User_Form.Width)
User_Form.Top = Application.Top + (0.5 * Application.Height) - (0.5 * User_Form.Height)

User_Form.Show

End Sub

Lives in Module 2
Sub UpdateFormulaButton()
'
' UpdateFormulaButton Macro

Range("F5:L5").Select
Selection.AutoFill Destination:=Range("TrainingTable[[Name]:[Quarter]]")
Range("TrainingTable[[Name]:[Quarter]]").Select

End Sub



1585259149800.png
1585259169709.png
 

Some videos you may like

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,402
Do you have any event code in the worksheet code area? Can you show a screen-shot of the explorer window that pops up?
 

Watch MrExcel Video

Forum statistics

Threads
1,118,138
Messages
5,570,382
Members
412,321
Latest member
Yusuf_A
Top