View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Grace[_4_] Grace[_4_] is offline
external usenet poster
 
Posts: 106
Default EXCEL VBA question

With a little learning on my part, this works nicely. Only a couple of
follow-up questions. Your macro codes the file as F. I know that before
each copy operation, I don't want to re-open the file, but would rather
activate it. I tried several versions of:

Windows("F.xls").Activate

and each yields a bug. What is the proper syntax for activating this file
we call F, after it has been opened?

One other thing, I use a similar command (that DOES work, for the name of
the file with the macro in it. Specifically:

Windows("test.xls").Activate

and that works fine. However, if I save the template with a new name, it
won't adjust to it. So, I need some way to tell it to always paste into the
current filename, the one with the macro. What is the best way to define
this, so I can activate it over and over again? I'm thinking of something
like G = the current filename with this macro, then I activate G over and
over again as I am pasting

Great work. Thanks!

"Harald Staff" wrote in message
...
Hi Jill

See if you can use this:

Sub test()
Dim F As Variant
F = Application.GetOpenFilename("Workbooks (*.xls), *.xls", _
, "Select a file to copy into:")
If F = False Then Exit Sub
Workbooks.Open F
End Sub

HTH. Best wishes Harald

"Grace" skrev i melding
...
Hi EXCEL VBA Wizards!

I keep improving a template I use but each time I improve it, I need to
retest it with data from a number of past examples to make sure I

haven't
compromised any functionality. In effect, I need to copy and paste

various
blocks of data from the same-named worksheet of an old file to the
same-named worksheet (and locations) of the new template. I think I can

do
this via simple recording of the macro. The only thing I don't know is

the
code to have it, at the outset, ask me what the name of the other EXCEL

file
is and, then, how to tell it to go to that filename, before each copy
command. Can you help me, please, with the specific coding to do this?

I'm thinking something like:

1) have it ask the user via some sort of input message box, for the

filename
I want to use for copying into the current file that will contain the

macro.

2) assign the response and identify it as "X"

3) go to filename X.xls

Thank you,
Jill