Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default copying and pasting range problem

Hi,

This is a continuation to a previous thread.

I have developed the macro below to take a number from a dataset (in
"Sheet1"), copy and paste it into a model (in "Sheet2") and then copy and
paste the model output back over a different range of columns in the
original dataset (in "Sheet1").

Sub Macro()
Dim cell As Range
For Each cell In Worksheets("Sheet1").Range("Range1")
cell.Resize(1, 1).Copy

With Worksheets("Sheet2")
.Range("Cell1").PasteSpecial Paste:=xlValues, Transpose:=True
cell.Offset(0, 9).Value = .Range("Cell2").Value
End With
Next
End Sub


Here is my issue: rather than simply pasting one value from "Cell2" back
into "Sheet1", I would like to paste transposed a "Range2" of 70 values back
into "Sheet1", offsetting this value [0,9] from "Range1". I tried the
following solution:

With Worksheets("Sheet2")
.Range("Cell1").PasteSpecial Paste:=xlValues, Transpose:=True
cell.Offset(0, 9).Resize(1, 70).Value = .Range("Range2").Value
End With

However, this simply repeats the FIRST observation from "Range1" 70 times
accross the the correct range in "Sheet1". I obviously need it to paste ALL
of the remaining 69 observations.

Your help is much appreciated.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default copying and pasting range problem

Sub Macro()
Dim cell As Range
For Each cell In Worksheets("Sheet1").Range("Range1")
cell.Resize(1, 1).Copy

With Worksheets("Sheet2")
.Range("Cell1").PasteSpecial Paste:=xlValues, Transpose:=True
numcol = .Range("Range2").Columns.count
cell.Offset(0, 9).Resize(1,70).Value =
Application.Transpose(.Range("Range2").Value)
End With
Next
End Sub

--
Regards,
Tom Ogilvy


"Henrik" wrote in message
...
Hi,

This is a continuation to a previous thread.

I have developed the macro below to take a number from a dataset (in
"Sheet1"), copy and paste it into a model (in "Sheet2") and then copy and
paste the model output back over a different range of columns in the
original dataset (in "Sheet1").

Sub Macro()
Dim cell As Range
For Each cell In Worksheets("Sheet1").Range("Range1")
cell.Resize(1, 1).Copy

With Worksheets("Sheet2")
.Range("Cell1").PasteSpecial Paste:=xlValues, Transpose:=True
cell.Offset(0, 9).Value = .Range("Cell2").Value
End With
Next
End Sub


Here is my issue: rather than simply pasting one value from "Cell2" back
into "Sheet1", I would like to paste transposed a "Range2" of 70 values

back
into "Sheet1", offsetting this value [0,9] from "Range1". I tried the
following solution:

With Worksheets("Sheet2")
.Range("Cell1").PasteSpecial Paste:=xlValues, Transpose:=True
cell.Offset(0, 9).Resize(1, 70).Value = .Range("Range2").Value
End With

However, this simply repeats the FIRST observation from "Range1" 70 times
accross the the correct range in "Sheet1". I obviously need it to paste

ALL
of the remaining 69 observations.

Your help is much appreciated.




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
Copying formulas in range and pasting in a selection Billy B Excel Worksheet Functions 3 April 17th 09 06:52 PM
Copying and pasting from a range John Excel Worksheet Functions 3 June 6th 07 05:22 PM
Problem copying a range to a different workbook [email protected] Excel Programming 3 December 8th 04 01:43 AM
Problem copying range and pasting to multiple sheets Murphy Excel Programming 1 October 9th 03 07:13 PM
Finding a range for Copying & Pasting John R[_3_] Excel Programming 1 August 19th 03 03:54 PM


All times are GMT +1. The time now is 02:31 PM.

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

About Us

"It's about Microsoft Excel"