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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

bk

Active Member
Joined
Jun 2, 2002
Messages
387
Can you

have a cell in the worksheet be where the filename (and path) is located and then, just reference that cell after Filename:= ?

That's how I've often accomplished that; I assign the value of the cell to a variable (ex. myFileName) and handle it that way.

It should work the same way with a TextBox, Label or whatever else you want to try.

Maybe I misunderstood your Q.
 

almouchie

Board Regular
Joined
Dec 23, 2004
Messages
128
fill formula down till it find a blank cell

i have a macro & a formula to insert in a cell
i want to auto fill it down the rows until it finds a blank in a certain cell say B

it looks like this
Selection.AutoFill Destination:=Range("M3:M13"), Type:=xlFillDefault

i dont want to name the range but rather to fill down as long cell B is not blank

any help is appreciated
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,061
Office Version
  1. 365
Platform
  1. Windows
Why don't you u se GetOpenFileName?
 

almouchie

Board Regular
Joined
Dec 23, 2004
Messages
128
how would i do that GetOpenFileName
i didnt find anything to get me started on it
whats the code look like
 

Watch MrExcel Video

Forum statistics

Threads
1,118,820
Messages
5,574,508
Members
412,599
Latest member
Schu94
Top