View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Jared Jared is offline
external usenet poster
 
Posts: 109
Default how to paste multipule items

Amazing,

I don't know how to thanks
it works perfect

Thanks



"Dave Peterson" wrote:

Copy and paste each area separately.

(You want to leave B2:b3, B5:B7 unchanged, right?)

An alternative would be to use a macro.

Option Explicit
Sub testme01()

Dim RngToCopy As Range
Dim RngToCopyTopLeftCell As Range
Dim RngToCopyCell As Range

Dim DestTopLeftCell As Range
Dim DestCell As Range

Dim myRowOffset As Long
Dim myColOffset As Long

Set RngToCopy = Nothing
On Error Resume Next
Set RngToCopy = Application.InputBox _
(prompt:="Select a range to copy" & vbNewLine & _
"--first cell SELECTED will be used as top left cell!", _
Type:=8)
On Error GoTo 0

If RngToCopy Is Nothing Then
Exit Sub 'user hit cancel
End If

If RngToCopy.Areas.Count = 1 Then
MsgBox "Please select a range with more than one area!"
Exit Sub
End If

Set RngToCopyTopLeftCell = RngToCopy.Cells(1, 1)

Set DestTopLeftCell = Nothing
On Error Resume Next
Set DestTopLeftCell = Application.InputBox _
(prompt:="Select a single cell to paste", Type:=8).Areas(1).Cells(1)
On Error GoTo 0

If DestTopLeftCell Is Nothing Then
Exit Sub 'cancel!
End If

For Each RngToCopyCell In RngToCopy.Cells

Set DestCell = Nothing
On Error Resume Next
Set DestCell = DestTopLeftCell _
.Offset(RngToCopyCell.Row _
- RngToCopyTopLeftCell.Row, _
RngToCopyCell.Column _
- RngToCopyTopLeftCell.Column)
On Error GoTo 0

If DestCell Is Nothing Then
MsgBox "Source cell: " & RngToCopyCell.Address(0, 0) _
& " Not copied!" & vbLf _
& "Destination would be off the worksheet!"
Else
RngToCopyCell.Copy _
Destination:=DestCell
End If
Next RngToCopyCell

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


Jared wrote:

when i select more than one item: for example a1 a4 a8

how do i paste them into b1 so that the diierence between them will still
exist. and not b1 b2 b3 but b1 b4 b8?

thanks
jared


--

Dave Peterson