Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Macro that is designed to paste text into worksheet cell does not work as expected in Excel


View products that this article applies to.

Symptoms

In Microsoft Excel, when you record a macro designed to automatically paste text into a worksheet cell, the macro may not work as expected.

↑ Back to the top


Cause

This behavior can occur if you include the Use Text Import Wizard command (under the Paste Options button) in the macro. See the "More Information" section of this article for further details.

↑ Back to the top


Workaround

To work around this issue, record a macro that uses the Paste command, and which then uses the Text to Columns command on the Data menu to parse the data.

To do this, follow these steps.

NOTE: You must already have data copied into the Clipboard memory.
  1. On the Tools menu in Excel, point to Macro, and then click Record New Macro.

    Note If you use Microsoft Office Excel 2007, click Record Macro in the Code group on the Developer tab.
  2. Name the macro, and then click OK.
  3. Select the cell that you want to paste the data into, and then click Paste on the Edit menu.

    Note If you use Excel 2007, click Paste in the Clipboard group on the Home tab.
  4. On the Data menu, click Text to Columns.
  5. Follow the instructions in the Convert Text to Columns Wizard, and then click Finish in step 3 of 3.
  6. On the Record New Macro toolbar, click Stop.

    Note If you use Excel 2007, click Stop Recording in the Code group on the Developer tab.

    The macro now works as expected.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

The Use the Text Import Wizard option in the Paste Options dialog box becomes available whenever Excel interprets the text that you are pasting as a type that would need to be parsed for it to be pasted correctly. Examples of this include plain text, lists that are separated by commas or semicolons, and text that resembles HTML code.

↑ Back to the top


Keywords: KB280604, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 280604
Revision : 4
Created on : 2/8/2007
Published on : 2/8/2007
Exists online : False
Views : 282