PC Review


Reply
Thread Tools Rate Thread

Copy/Paste from Different Worksheet

 
 
Jeff Gross
Guest
Posts: n/a
 
      4th Jun 2009
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.
 
Reply With Quote
 
 
 
 
Jennifer
Guest
Posts: n/a
 
      4th Jun 2009
On Jun 4, 3:21*pm, Jeff Gross <JeffGr...@discussions.microsoft.com>
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 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
 
Reply With Quote
 
Jeff Gross
Guest
Posts: n/a
 
      5th Jun 2009
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 <JeffGr...@discussions.microsoft.com>
> 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
>

 
Reply With Quote
 
Jeff Gross
Guest
Posts: n/a
 
      5th Jun 2009
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 <JeffGr...@discussions.microsoft.com>
> 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
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy & paste worksheet with print settings into new worksheet Larry Ohio Microsoft Excel Misc 1 23rd Dec 2009 05:17 PM
Copy data from one worksheet and paste into another worksheet stockton12 Microsoft Excel Programming 3 30th Mar 2008 09:40 PM
Copy & paste cells fr open worksheet then close the worksheet =?Utf-8?B?U2lu?= Microsoft Excel Programming 1 2nd Oct 2006 02:20 PM
Re: excel 97: copy and paste values from one worksheet to another worksheet JMCN Microsoft Excel Programming 2 23rd Sep 2003 01:32 PM
excel 97: copy and paste values from one worksheet to another worksheet Kathy Microsoft Excel Programming 0 21st Sep 2003 03:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:35 AM.