Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying from a word table to an excel table with line breaks in 1 cell

Status
Not open for further replies.

thanos54321

Programmer
Jan 3, 2005
24
DK
Hi, I couldn't find any threads containing this issue, and I'm very rusty on VBA at the moment, so I need some help.

Specifically, I'm trying to select some text like


that is, text including soft line breaks, in word, and copying to excel. The problem is, excel thinks the line breaks indicate that the next line is put into a new cell.

An easy manual way around this is to select the cell in excel, press F2 and paste it. Hooray!

Now comes the tricky part (for me at least): I want to replicate this move in a macro, but if I just record it, the code includes the actual text pasted (as in the same text every time), instead of what happens to be in the clipboard. This I'm absolutely blank on how to do. Can you help?


Finally, a refinement is that the first line is ALWAYS a headline, that I want to clip out, delete the blank line, and move the header to the cell to the left in excel. Is this possible? Example:

1:
Headline
BlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablabla
BlablablablaBlablablablaBlablablablaBlablablablaBlablab
BlablablablaBlablablablaBlablablabla

2:
'clipped out: Headline, but the empty line is still there'
BlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablabla
BlablablablaBlablablablaBlablablablaBlablablablaBlablab
BlablablablaBlablablablaBlablablabla

3:
BlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablablaBlablablabla
BlablablablaBlablablablaBlablablablaBlablablablaBlablab
BlablablablaBlablablablaBlablablabla

4: paste Headline in the cell to the left

I hope you're able to help, and I thank you for your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top