Copy/Paste from Different Worksheet

J

Jeff Gross

I posted this earlier but received no response so I'm hoping to have better
luck this time.

I have a possible of 300 rows of data on sheet2 (this is variable but no
more than 300). Column A on sheet2 is currently blank. The data starts in
column B of sheet2 and is the result of an "IF" type formula.

What I need the code to do is starting with row 2 on sheet2, look for data
in B2. If the result of the "IF" statement in B2 results in a blank cell
for B2, then go to the
next row and repeat for row 3. If there is data in B2, copy the data in a
cell from a
different worksheet (sheet1 $C$4) into this cell and then continue on to row
3.

I think I have explained it sufficiently so any help would be greatly
appreciated.
 
J

Jennifer

I posted this earlier but received no response so I'm hoping to have better
luck this time.

I have a possible of 300 rows of data on sheet2 (this is variable but no
more than 300).  Column A on sheet2 is currently blank.  The data starts in
column B of sheet2 and is the result of an "IF" type formula.

What I need the code to do is starting with row 2 on sheet2, look for data
in B2.  If  the result of the "IF" statement in B2 results in a blankcell
for B2, then go to the
next row and repeat for row 3.  If there is data in B2, copy the data in a
cell from a
different worksheet (sheet1 $C$4) into this cell and then continue on to row
3.

I think I have explained it sufficiently so any help would be greatly
appreciated.

Sub CopyMacro()
Dim X As Integer
For X = 2 To 301
If Sheet2.Cells(X, 2).Value <> "" Then
Sheet2.Cells(X, 2).Value = Sheet1.Cells(4, 3).Value
End If
Next X
End Sub
 
J

Jeff Gross

Thanks for the help. One last question...

How do I reference the worksheets if the names are changed to something like
"Sheet Data 1" and "Sheet Data 2"?

Jeff
 
J

Jeff Gross

Thanks Jennifer but I figured it out. I changed the code to :

Sub CopyMacro()

Dim X As Integer
For X = 2 To 301
If Worksheets(7).Cells(X, 2).Value <> "" Then
Worksheets(7).Cells(X, 1).Value = Worksheets(2).Cells(4, 3).Value
End If
Next X
End Sub

It does exactly what I needed - thanks again.

Jeff
 

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