command button with labels to choose which file

almouchie

Board Regular
Joined
Dec 23, 2004
Messages
128
I have this simple code


Sub OpenFile()

ChDir "M:\George-Rola\DECEMBER"
Workbooks.Open Filename:="M:\George-Rola\DECEMBER\INVOICES-620.xls"
End Sub


but I want to have a text label in my sheet to write down which file to open, or several files & click the command button to open these file , or use these file for data input
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,119
Office Version
  1. 2016
Platform
  1. Windows
Hi,

What do you mean by text labels in your sheet ? How do the labels get their text ? which commandbutton do you have to click ?

It would be helpful if you could elaborate more .

Regards.
 

almouchie

Board Regular
Joined
Dec 23, 2004
Messages
128
salam

tx for ur reply

maybe i should have elaborated more

i have a database with all invoice related data by date, supplier, & type & other data

& i have the individual invoices in different workboooks

i want to update the master file(database) with the number in each invoice
some needs calculation & multiplication of tariffs


i thought i would create a a text box to write in it the invoice file to open & take the data from it
& then click the command button to file the fields accordingly

i dont know where to start
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,119
Office Version
  1. 2016
Platform
  1. Windows
Hi almouchie,

If I understand you right, you can just assign your OpenFile sub to the Button and pass the TextBox value as the Workbooks.Open argument:

Code:
Sub OpenFile() 

     ChDir "M:\George-Rola\DECEMBER" 
     Workbooks.Open TextBox1.text

End Sub


Regards.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,359
Messages
5,601,153
Members
414,431
Latest member
JustmemyselfandI

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