Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
Not excelling at macros
 
Posts: n/a
Default pasting non-contiguous range of cells to new row, same cell locati

I need a paste macro that will paste a non-contiguous range of cells (ie
"A1:B1,G1")
to the current row in the same column locations (ie "A5:B5,G5"), assuming
current row is 5th row.

Does anyone have code for this need that you can share?
  #2   Report Post  
Posted to microsoft.public.excel.newusers
Ron de Bruin
 
Posts: n/a
Default pasting non-contiguous range of cells to new row, same cell locati

Try this

Sub test()
Range("A1:B1").Copy Cells(ActiveCell.Row, "A")
Range("G1").Copy Cells(ActiveCell.Row, "G")
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Not excelling at macros" <Not excelling at wrote in message
...
I need a paste macro that will paste a non-contiguous range of cells (ie
"A1:B1,G1")
to the current row in the same column locations (ie "A5:B5,G5"), assuming
current row is 5th row.

Does anyone have code for this need that you can share?



  #3   Report Post  
Posted to microsoft.public.excel.newusers
Not excelling at macros
 
Posts: n/a
Default pasting non-contiguous range of cells to new row, same cell lo

This works great for known source/target rows, but I need it to be dynamic.
So, I click the current row and use a copy macro to select those specific
cells. Then, I need to click on the target row and use a paste macro to
paste to those specific cells.

Your suggestion works great, I just need one more tweak. Any suggestions?

Thanks Ron!

"Ron de Bruin" wrote:

Try this

Sub test()
Range("A1:B1").Copy Cells(ActiveCell.Row, "A")
Range("G1").Copy Cells(ActiveCell.Row, "G")
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Not excelling at macros" <Not excelling at wrote in message
...
I need a paste macro that will paste a non-contiguous range of cells (ie
"A1:B1,G1")
to the current row in the same column locations (ie "A5:B5,G5"), assuming
current row is 5th row.

Does anyone have code for this need that you can share?




  #4   Report Post  
Posted to microsoft.public.excel.newusers
Ron de Bruin
 
Posts: n/a
Default pasting non-contiguous range of cells to new row, same cell lo

Try this tester

Sub test()
Dim arr() As String
Dim N As Integer
Dim cell As Range
Dim destrow As Range
Dim selectionrow
Dim I As Integer

If Selection.Rows.Count 1 Then Exit Sub
selectionrow = Selection.Row
N = 0
For Each cell In Selection
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = cell.Column
Next cell
On Error Resume Next
Set destrow = Application.InputBox("select a cell in the Destination row", Type:=8)
If destrow Is Nothing Then
On Error GoTo 0
Exit Sub
Else
For I = 1 To N
Cells(destrow.Cells(1).Row, Val(arr(I))) = Cells(selectionrow, Val(arr(I)))
Next I
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Not excelling at macros" wrote in message
...
This works great for known source/target rows, but I need it to be dynamic.
So, I click the current row and use a copy macro to select those specific
cells. Then, I need to click on the target row and use a paste macro to
paste to those specific cells.

Your suggestion works great, I just need one more tweak. Any suggestions?

Thanks Ron!

"Ron de Bruin" wrote:

Try this

Sub test()
Range("A1:B1").Copy Cells(ActiveCell.Row, "A")
Range("G1").Copy Cells(ActiveCell.Row, "G")
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Not excelling at macros" <Not excelling at wrote in message
...
I need a paste macro that will paste a non-contiguous range of cells (ie
"A1:B1,G1")
to the current row in the same column locations (ie "A5:B5,G5"), assuming
current row is 5th row.

Does anyone have code for this need that you can share?






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
how do i format a cell based on format of a range of cells? Chris Hardick Excel Discussion (Misc queries) 2 April 3rd 06 08:54 AM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
How can I assign a range starting cell based on a variable locati. feman007 Excel Worksheet Functions 3 March 9th 05 11:40 PM
Merging Cells but have each cell counted in the range of merged c. gats13 Excel Worksheet Functions 2 November 9th 04 07:14 PM
How do you delete one cell from a range of protected cells Cgbilliar Excel Worksheet Functions 2 November 3rd 04 10:42 PM


All times are GMT +1. The time now is 05:10 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"