Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
pedro AM
 
Posts: n/a
Default Copy and paste automatically

Hi all

I am trying to create a macro that copies from a txt file into excel but it
does not work.

I have a excel file with 12 sheets (one for each month) and in each 5
columns headed
year, period,account,location,value.

I want it to get info from a txt file that may change every month and paste
it in columns C,D and E.
The problem is that it doesn't give me the chance to, everytime I run it,
choose what tab to paste it to.
Is there a way to create this macro?

Any help would be very much appreciated. I have excel 2000 pro.

Thanks

  #2   Report Post  
Jezebel
 
Posts: n/a
Default Copy and paste automatically

You'll need to provide a little more information. There are any number of
ways for a macro to get information from the user -- what method are you
trying to use at the moment, and what doesn't work?



"pedro AM" wrote in message
...
Hi all

I am trying to create a macro that copies from a txt file into excel but
it
does not work.

I have a excel file with 12 sheets (one for each month) and in each 5
columns headed
year, period,account,location,value.

I want it to get info from a txt file that may change every month and
paste
it in columns C,D and E.
The problem is that it doesn't give me the chance to, everytime I run it,
choose what tab to paste it to.
Is there a way to create this macro?

Any help would be very much appreciated. I have excel 2000 pro.

Thanks



  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default Copy and paste automatically

I think I'd run the macro from the sheet where I wanted it pasted.

Then I could just use Activesheet.

dim CurWks as worksheet
dim txtWks as worksheet

set curwks = activesheet
set txtwks = workbooks.open(your stuff to open the text file).worksheets(1)

txtwks.range("a:c").copy _
destination:=curwks.range("a1")




pedro AM wrote:

Hi all

I am trying to create a macro that copies from a txt file into excel but it
does not work.

I have a excel file with 12 sheets (one for each month) and in each 5
columns headed
year, period,account,location,value.

I want it to get info from a txt file that may change every month and paste
it in columns C,D and E.
The problem is that it doesn't give me the chance to, everytime I run it,
choose what tab to paste it to.
Is there a way to create this macro?

Any help would be very much appreciated. I have excel 2000 pro.

Thanks


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
pedro AM
 
Posts: n/a
Default Copy and paste automatically

Hi Dave and Jezebel

Unfortunately I am not as good with VB as to be able to write that coding in
the macro and make sense of it.

I have tried to create a macro by going through the macro:create menu in
Excel.
I just do =data:get external data: select the file and import the data
(separator=semicolon,do not import first column) and paste in a chosen cell
this works well with the macro.
However, when I try the macro again to upload another file into another
sheet it does not give me the choice to either open a different txt file nor
to chose a different cell to paste it to.

It is in the file to import info to and not in the one to manage all
processes.

Do you have any idea as how can I set the parameters?

thank you
"Dave Peterson" wrote:

I think I'd run the macro from the sheet where I wanted it pasted.

Then I could just use Activesheet.

dim CurWks as worksheet
dim txtWks as worksheet

set curwks = activesheet
set txtwks = workbooks.open(your stuff to open the text file).worksheets(1)

txtwks.range("a:c").copy _
destination:=curwks.range("a1")




pedro AM wrote:

Hi all

I am trying to create a macro that copies from a txt file into excel but it
does not work.

I have a excel file with 12 sheets (one for each month) and in each 5
columns headed
year, period,account,location,value.

I want it to get info from a txt file that may change every month and paste
it in columns C,D and E.
The problem is that it doesn't give me the chance to, everytime I run it,
choose what tab to paste it to.
Is there a way to create this macro?

Any help would be very much appreciated. I have excel 2000 pro.

Thanks


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Copy and paste automatically

You can get the filename from the user (you??) with something like:

dim myFileName as variant

myfilename = application.getopenfilename(filefilter:="Excel Files, *.xls")
if myfilename = false then
exit sub 'user hit cancel
end if

then use myfilename in place of the filename specified in your recorded macro.



pedro AM wrote:

Hi Dave and Jezebel

Unfortunately I am not as good with VB as to be able to write that coding in
the macro and make sense of it.

I have tried to create a macro by going through the macro:create menu in
Excel.
I just do =data:get external data: select the file and import the data
(separator=semicolon,do not import first column) and paste in a chosen cell
this works well with the macro.
However, when I try the macro again to upload another file into another
sheet it does not give me the choice to either open a different txt file nor
to chose a different cell to paste it to.

It is in the file to import info to and not in the one to manage all
processes.

Do you have any idea as how can I set the parameters?

thank you
"Dave Peterson" wrote:

I think I'd run the macro from the sheet where I wanted it pasted.

Then I could just use Activesheet.

dim CurWks as worksheet
dim txtWks as worksheet

set curwks = activesheet
set txtwks = workbooks.open(your stuff to open the text file).worksheets(1)

txtwks.range("a:c").copy _
destination:=curwks.range("a1")




pedro AM wrote:

Hi all

I am trying to create a macro that copies from a txt file into excel but it
does not work.

I have a excel file with 12 sheets (one for each month) and in each 5
columns headed
year, period,account,location,value.

I want it to get info from a txt file that may change every month and paste
it in columns C,D and E.
The problem is that it doesn't give me the chance to, everytime I run it,
choose what tab to paste it to.
Is there a way to create this macro?

Any help would be very much appreciated. I have excel 2000 pro.

Thanks


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
Can't Copy and Paste foumulas? Emory Richter Excel Discussion (Misc queries) 2 October 1st 05 08:27 PM
I cannot paste from one workbook to another. Copy works, paste do. JimmyMc Excel Discussion (Misc queries) 1 June 10th 05 03:54 PM
Can't Copy and Paste between Excel 2003 Workbooks wllee Excel Discussion (Misc queries) 6 March 30th 05 02:59 PM
Copy and Paste and keep format the same Brian Caraher Excel Discussion (Misc queries) 1 March 17th 05 02:05 PM


All times are GMT +1. The time now is 06:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"