Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 109
Default how to paste multipule items

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default how to paste multipule items

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
  #3   Report Post  
Posted to microsoft.public.excel.misc
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd Copy and Paste BillCPA Excel Discussion (Misc queries) 3 April 4th 06 07:34 PM
Paste Special and Linking ajkim001 Excel Discussion (Misc queries) 8 March 14th 06 03:10 PM
Paste Special Problem ajkim001 Excel Discussion (Misc queries) 1 March 11th 06 12:50 AM
Copy / Paste Warning wbmcse Excel Discussion (Misc queries) 0 March 3rd 06 08:04 PM
Can't Copy and Paste foumulas? Emory Richter Excel Discussion (Misc queries) 2 October 1st 05 09:27 PM


All times are GMT +1. The time now is 06:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"