ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy/Paste from Different Worksheet (https://www.excelbanter.com/excel-programming/429401-copy-paste-different-worksheet.html)

Jeff Gross

Copy/Paste from Different Worksheet
 
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.

Jennifer[_2_]

Copy/Paste from Different Worksheet
 
On Jun 4, 3:21*pm, Jeff Gross
wrote:
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.


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

Jennifer[_2_]

Copy/Paste from Different Worksheet
 
On Jun 4, 3:21*pm, Jeff Gross
wrote:
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.


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

Jeff Gross

Copy/Paste from Different Worksheet
 
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

"Jennifer" wrote:

On Jun 4, 3:21 pm, Jeff Gross
wrote:
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.


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


Jeff Gross

Copy/Paste from Different Worksheet
 
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

"Jennifer" wrote:

On Jun 4, 3:21 pm, Jeff Gross
wrote:
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.


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



All times are GMT +1. The time now is 03:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com