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
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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.
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,378
Members
448,955
Latest member
BatCoder

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