Code to cut and paste text from continuous cells to make a document such as a memo or narrative

S

Steve G

Frequently I have text in various cells in Excel. For instance, A1,
A2, A3 might have text only in these cell. There might be a different
sentence in each cell. I would like to cut the text from A2 and A3 in
that order and append it to the text in A1 without doing cuts and
pastes. The cells would always be contiguous as in my example.
Better yet, if there was a wizard that let me name the cells from
which I want to take text out of and the cell that I want to paste
text into, that would be best.

Thank you.

Steve G
 
G

Guest

Is something like this whatt you are looking for?

Sub cutandpaste()

OldCell = InputBox("Enter Cell to copy")
NewCell = InputBox("Enter Cell to Paste")

Range(NewCell).Value = Range(NewCell).Value & Range(OldCell).Value

End Sub
 
F

Ferris

Frequently I have text in various cells in Excel. For instance, A1,
A2, A3 might have text only in these cell. There might be a different
sentence in each cell. I would like to cut the text from A2 and A3 in
that order and append it to the text in A1 without doing cuts and
pastes. The cells would always be contiguous as in my example.
Better yet, if there was a wizard that let me name the cells from
which I want to take text out of and the cell that I want to paste
text into, that would be best.

Thank you.

Steve G

If you select the cells in the order you want them, then this should
work. It will prompt you for the destination cell.

Sub test()
Dim rng As Range, rngPaste As Range

Set rng = Selection
Text = ""
For Each c In rng
Text = Text & c.Value
Next
Set rngPaste = Application.InputBox _
(Prompt:="Please select the destination cell", Type:=8)

If Not rngPaste Is Nothing Then
rngPaste.Value = Text
End If

End Sub
 
S

Steve G

Ferris--

Does it work like this:

I put the macro in my personal.xls. I open the file with the text.
Do I highlight/select the cells I want to transfer the text from?
Then I run the macro. The macro asks me for input. I type in C5 or
D7 or whatever cell I want the text to go into. I hit "enter."

Thank you for your assistance.

Steve G
 
F

Ferris

Ferris--

Does it work like this:

I put the macro in my personal.xls. I open the file with the text.
Do I highlight/select the cells I want to transfer the text from?
Then I run the macro. The macro asks me for input. I type in C5 or
D7 or whatever cell I want the text to go into. I hit "enter."

Thank you for your assistance.

Steve G

Yeah, it should work pretty much like that. If you have Excel 2003 or
earlier I'd throw a button on the toolbar to make it accessible. You
don't have to type in the cell reference, you should be able to click
anywhere on the sheet and the cell reference should appear in the
input box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top