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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,069
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,069
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,118,727
Messages
5,573,853
Members
412,554
Latest member
faridr
Top