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

Hi,

I am in great need of a macro that can do the following:

In Sheet1, columns A, B, and C there are three arrays of
variables. I need to copy, line by line, a variable from
each array and paste (as values) these three variables
into 3 different cells in Sheet2 (let's say B3, B10, B12).
I would prefer if the macro copied and pasted the 3
variables independently of each other rather simply
selecting the range (A1:C1). The input into the three
cells in Sheet2 will change the output in cells C12, C15,
and C20 (also in Sheet2). I then want to copy this output
and record it (i.e. paste it) in columns D, E, and F in
Sheet1 (again preferably independently each other rather
than selecting a range). I need the procedure above
performed line by line as the arrays range from cell row 1
to 20. That is, I need to procedure performed for (Sheet1)
row 1, then row 2, and so forth. Any ideas of how to do
this? Your help is greatly appreciated.

Kenneth Smith

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default copying and pasting loop

Kenneth

Try this

Sub test()

Dim cell As Range
Dim sh1 As Worksheet, sh2 As Worksheet

Set sh1 = ThisWorkbook.Sheets("Sheet1")
Set sh2 = ThisWorkbook.Sheets("Sheet2")

For Each cell In sh1.Range("A1:A20")
sh2.Range("b3").Value = cell.Value
sh2.Range("b10").Value = cell.Offset(0, 1).Value
sh2.Range("b12").Value = cell.Offset(0, 2).Value
cell.Offset(0, 3).Value = sh2.Range("c12").Value
cell.Offset(0, 4).Value = sh2.Range("c15").Value
cell.Offset(0, 5).Value = sh2.Range("C20").Value
Next cell

End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Kenneth Smith" wrote in message
...
Hi,

I am in great need of a macro that can do the following:

In Sheet1, columns A, B, and C there are three arrays of
variables. I need to copy, line by line, a variable from
each array and paste (as values) these three variables
into 3 different cells in Sheet2 (let's say B3, B10, B12).
I would prefer if the macro copied and pasted the 3
variables independently of each other rather simply
selecting the range (A1:C1). The input into the three
cells in Sheet2 will change the output in cells C12, C15,
and C20 (also in Sheet2). I then want to copy this output
and record it (i.e. paste it) in columns D, E, and F in
Sheet1 (again preferably independently each other rather
than selecting a range). I need the procedure above
performed line by line as the arrays range from cell row 1
to 20. That is, I need to procedure performed for (Sheet1)
row 1, then row 2, and so forth. Any ideas of how to do
this? Your help is greatly appreciated.

Kenneth Smith



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 & Pasting sjmonroe Excel Discussion (Misc queries) 5 November 20th 09 09:32 PM
Copying and Pasting Minnie Excel Discussion (Misc queries) 10 December 11th 08 02:53 PM
Copying and pasting ??? NorcalTruck Excel Discussion (Misc queries) 3 December 27th 05 08:31 PM
Setting up some sort of cutting and pasting loop Trickster Excel Worksheet Functions 4 July 20th 05 07:13 AM
Copying and Pasting Tia Excel Discussion (Misc queries) 4 June 6th 05 08:54 PM


All times are GMT +1. The time now is 04:55 PM.

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"