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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,519
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,122,528
Messages
5,596,690
Members
414,088
Latest member
rodriboraun

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
Top