PC Review


Reply
Thread Tools Rate Thread

Basic macro for copying into Excel

 
 
Moo
Guest
Posts: n/a
 
      22nd Mar 2007
I am trying to create a very basic macro in Excel, but keeping coming
unstuck and hope someone can help.

I am trying to copy some text fields from an old DOS based programme
into Excel. If you simply copy and paste, the text will copy itself
into one cell only as a long string of text.

I want to separate this text into different columns; the manual way of
doing it is to click on paste options, use text import wizard, setting
the columns as fixed width. I have tried recording this as a macro,
but it is not working at all.

Any suggestions on a basic macro to copy this data in as separate
columns?

Thanks.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      22nd Mar 2007
You need to paste it in first, then use data=>Text to Columns to do the same
as you describe. If do it that way with the recorder on, you will get the
code you need.

--
Regards,
Tom Ogilvy


"Moo" wrote:

> I am trying to create a very basic macro in Excel, but keeping coming
> unstuck and hope someone can help.
>
> I am trying to copy some text fields from an old DOS based programme
> into Excel. If you simply copy and paste, the text will copy itself
> into one cell only as a long string of text.
>
> I want to separate this text into different columns; the manual way of
> doing it is to click on paste options, use text import wizard, setting
> the columns as fixed width. I have tried recording this as a macro,
> but it is not working at all.
>
> Any suggestions on a basic macro to copy this data in as separate
> columns?
>
> Thanks.
>
>

 
Reply With Quote
 
Moo
Guest
Posts: n/a
 
      22nd Mar 2007
Tom,

Thanks for your response. I've just tried that and it mainly works.
However, how do I get the pasting to go into the cells I've
highlighted (current cell), rather than cell A3, which is what I
recorded the original macro from (see code below):

ActiveSheet.Paste
Selection.TextToColumns Destination:=Range("A3"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(8, 1), Array(14, 1),
Array(21, 1), Array(26, 1), _
Array(53, 9), Array(55, 1)), TrailingMinusNumbers:=True
End Sub

I also keep getting the following message when running the macro, even
though the cells I'm pasting into are blank and I have turned off the
option to prompt when overwriting text! "Do you want to replace the
contents of the destination cells?"

Thanks.

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      22nd Mar 2007
Selection.TextToColumns Destination:=Range("A3"),

would become

Selection.TextToColumns Destination:=ActiveCell,


I suspect.

--
Regards,
Tom Ogilvy


"Moo" wrote:

> Tom,
>
> Thanks for your response. I've just tried that and it mainly works.
> However, how do I get the pasting to go into the cells I've
> highlighted (current cell), rather than cell A3, which is what I
> recorded the original macro from (see code below):
>
> ActiveSheet.Paste
> Selection.TextToColumns Destination:=Range("A3"),
> DataType:=xlFixedWidth, _
> FieldInfo:=Array(Array(0, 1), Array(8, 1), Array(14, 1),
> Array(21, 1), Array(26, 1), _
> Array(53, 9), Array(55, 1)), TrailingMinusNumbers:=True
> End Sub
>
> I also keep getting the following message when running the macro, even
> though the cells I'm pasting into are blank and I have turned off the
> option to prompt when overwriting text! "Do you want to replace the
> contents of the destination cells?"
>
> Thanks.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set up basic Macro in EXcel to use in other applications =?Utf-8?B?RXhjZWwgcmVjb3JkZWQgbWFjcm9zIHVzZWQgaW4g Microsoft Excel Misc 0 31st Aug 2005 01:32 PM
Some Basic Doubts in Excel Macro Manu Microsoft Excel Programming 1 20th Feb 2005 12:16 PM
how can used the macro visual basic in excel nader Microsoft Excel Discussion 7 29th Jun 2004 02:36 AM
Excel Macro Basic Help Adam Microsoft Excel Programming 2 18th May 2004 02:45 PM
visual basic macro in excel Patrick Molloy Microsoft Excel Programming 0 23rd Jul 2003 09:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:19 AM.