View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default asking for a file

Sub Parcourir()
FichierAOuvrir = Application.GetOpenFilename
If FichierAOuvrir < Faux Then
TextBox1.Text = FichierAOuvrir
End If

set sh = Activesheet
set wkbk = workbooks.open(Filename:=FichierAOuvrir)
sh.UsedRange.copy
wkbk.workbooks(2).Cells(rows.count,1).End(xlup)(2) .Paste xlValues
wkbk.Close Savechanges:=True
End Sub



--
Regards,
Tom Ogilvy

"Marie Lavoie" wrote in message
...
"userform1.textbox1.text" .... doh.
Ok.
But still, my question about copying a worksheet hasn't been answered.

Marie

"Marie Lavoie" a écrit dans le message de
...
Could someone tell me whats wrong with the code below?

Sub Parcourir()
FichierAOuvrir = Application.GetOpenFilename
If FichierAOuvrir < Faux Then
TextBox1.Text = FichierAOuvrir
End If
End Sub


I want to have a textbox where the file name with it's whole path

appears.
I wrote this in a blank sheet as a test. Btq, TextBox1 exists and
FichierAOuvrir is declared as string. But is shows mistakes.
At first my 3rd line was "If FichierAOuvrir < False Then" ans it kept
bugging, so I put "faux" ans it works... Frustrating to program with a
french VB... what a weird Idea to put french words like this... anyway.
Now, I know that FichierAOuvrir = "Path is written here"
But it doesn't like the "TextBo1.Text = FichierAOuvrir". Could you tell

me
whats wrong?

Thnak you for your help.

Marie


"Marie Lavoie" a écrit dans le message de
...
That helped me, ty. And you answered to my question, as I wanted to

open
a
file.
But may the code add the sheets to the ones I have right now? Or do I

need
to make the macro open the file, copy selected sheet, paste in first

work
sheet??

Marie

"Kris" a écrit dans le message

de
...
Marie,

Dim Myfilename as String

Myfilename = Application.GetOpenFilename
Workbooks.Open FileName:=MyFilename

Regards,
Kris

-----Original Message-----
Hi, I wondered if there would be a command so that it
asks the user to chose
what file to open.

I've made a program that updates the info in the second
sheet when you press
the button in the first sheet. But I'd need to keep the
result of the
previous month in the second sheet before updating. So
right now, the user
has to copy the information. Is there a way that the
programs open a "open"
box where he selects the excel file and that it copies
it in the 2nd sheet?
(And if you have even better ideas, you may submit it ;-
) )

Thank you.

Marie


.