Jump to content
Macro Express Forums

Excel Copy Help


tatrader

Recommended Posts

I am trying to write a macro that sequentially reads and copies a series of 5 cells in a row of Excel into corresponding text variables. Activating Excel and locating the cells of interest is working ok.

 

With a cell highlighted, I try to copy: text type macro: "controldown,C,countroup"

 

I notice that Excel does not turn the frame around the selected cell to 'marching ants' when the macro attempts to copy it; however, marching ants does occur when I actually enter ctrlC on the keyboard. I then set a text variable with the contents of the clipboard, and I see from the debug variable table that no information resides in the text variable. I want to treat the copied value (shown as a number in Excel cell) as text so I can then paste it into another different application.

 

Does it matter for copy into a text variable if numbers are shown in the Excel cell? What if the cell format is set to "text" in Excel?

 

Help appreciated.

Link to comment
Share on other sites

tatrader,

 

Simple enough.. replace "text type macro: "controldown,C,countroup" with "Clipboard Copy". The cell already has focus... there is no reason to texttype.

 

Clipboard Copy

Variable Set String %T1% from Clipboard

Text Type: <ARROW RIGHT>

Clipboard Copy

Variable Set String %T2% from Clipboard

Text Type: <ARROW RIGHT>

Clipboard Copy

Variable Set String %T3% from Clipboard

Text Type: <ARROW RIGHT>

Clipboard Copy

Variable Set String %T4% from Clipboard

Text Type: <ARROW RIGHT>

Clipboard Copy

Variable Set String %T5% from Clipboard

Text Type: <ARROW RIGHT>

Link to comment
Share on other sites

Thanks Cyberchief,

 

The clipboard copy works in copying the contents of the Excel cell with focus. It causes the marching ants to appear around the cell copied. However, the text type: <rightarrow> following the copy of the first cell does not cause the focus to shift to the next right cell. Marching ants remain around the first cell. The copy for the second cell ends up with the value of the first cell.

 

Also, I notice in the value stored in the text variable has a symbol appearing like two small vertical bars following the value as shown in the Excel cell. Is this some type of format information? Can I get rid of it?

Link to comment
Share on other sites

I am not sure why the next "copy" would not switch focus. I use excel with every macro I build... I copy the first cell, arrow right, and copy again... If you copy one cell manually... and arrow right 10 times... you will see that the "marching ants' is still going around that first cell. this does not mean that it still has focus... if you clipboard copy again... on the new cell that you arrowed to, it will move the "marching ants" to the new cell. If it does not work with "arrow right"... try using tab.

 

Please post the script of the macro you are running... and I will see if I can find the error.

Link to comment
Share on other sites

Hi,

 

Sorry about about the last. I had an error. The righarrow and copy to clipboard actions are working ok. Thanks.

 

However, my question about symbol to the right of the copied value as appears in the text variable is still in issue. Since want to paste the text variables into another application, I need to delete whatever these symbols are.

Link to comment
Share on other sites

I think these are "Carriage Returns". Try this:

 

 

Clipboard Copy

Variable Set String %T1% from Clipboard

Variable Modify String: Strip CR/LF from %T1%

Text Type: <ARROW RIGHT>

Clipboard Copy

Variable Set String %T2% from Clipboard

Variable Modify String: Strip CR/LF from %T2%

Text Type: <ARROW RIGHT>

Clipboard Copy

Variable Set String %T3% from Clipboard

Variable Modify String: Strip CR/LF from %T3%

Text Type: <ARROW RIGHT>

Clipboard Copy

Variable Set String %T4% from Clipboard

Variable Modify String: Strip CR/LF from %T4%

Text Type: <ARROW RIGHT>

Clipboard Copy

Variable Set String %T5% from Clipboard

Variable Modify String: Strip CR/LF from %T5%

Text Type: <ARROW RIGHT>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...