Copy and Paste Loop

A

AK

Need help with how to write a loop function...

* Data in a list is in column A on Sheet1 - the number of entries in the
list may vary

* Starting from A1 on Sheet1 I need to copy the value and paste special the
value to Sheet 2 cell B1 - there are calculations that run based on the value
in B1

* I then copy a range from Sheet 2 and paste special to Sheet 3 - this part
I know how to write code for

* After the copy / paste of the range from Sheet 2 to Sheet 3, I need to go
back to Sheet 1 and select the next item in the list in column A - this would
be A2 in this example

* Then run through the copy/paste from Sheet 1 to Sheet 2 - run the
calculations - then copy/paste range from Sheet 2 to Sheet 3

* Repeat until the last record in the list in Column A on Sheet 1

THANK YOU IN ADVANCE!!!!
 
J

Jacob Skaria

Try the below...

Sub MyMacro()
Dim ws1 As Worksheet, ws2 As Worksheet, ws2 As Worksheet
Dim lngRow As Long

Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set ws3 = Sheets("Sheet3")

'Loop until last record of sheet1 ColA
For lngRow = 1 To ws1.Cells(Rows.Count, "A").End(xlUp).Row
'Copy each row of Sheet1 Col A to Sheet2 B1
ws1.Range("A" & lngRow).Copy ws2.Range("B1")
'Some calulations

'Copy from Sheet2 to Sheet3
'ws2.Range("A" & lngRow).Copy ws3.Range("B1")
Next
End Sub

If this post helps click Yes
 
P

Patrick Molloy

dim cell as range
set cell = worksheets("sheet1").Range("A1")
DO UNTIL Cell.Value = ""
Worksheets("Sheet2").Cells(cell.Row,"B").Value = cell.Value
set cell = cell.Offset(1)
LOOP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top