Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default copy and paste according to cell value

I'm looking for a macro that whenever I type "y" in "O" column it copy
corresponding cells from B:N to sheet 2 starting from B:5 and look for
another "y" in col. O and paste it below what it pasted before in sheet 2.

thx.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200801/1

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default copy and paste according to cell value

I found this macro, but the problem is that it copies duplicates. for example
if I type "y" in column O5 and run the macro and then type "y" in O6 it will
copy previous row which is O5 again.

Any idea how to make it not to copy the previous row again?

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim destCell As Range

With Worksheets("Daily")
Set myRng = .Range("O5:O92")
End With

For Each myCell In myRng.Cells
If LCase(myCell.Value) = "y" Then
With Worksheets("Funnel")

Set destCell = .Cells(.Rows.Count, "B").End(xlUp).Offset(1, 0)

End With
Range(myCell.Offset(0, -1), myCell.Offset(0, -13)).Copy _
Destination:=destCell
End If
Next myCell
End Sub

saman110 wrote:
I'm looking for a macro that whenever I type "y" in "O" column it copy
corresponding cells from B:N to sheet 2 starting from B:5 and look for
another "y" in col. O and paste it below what it pasted before in sheet 2.

thx.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200801/1

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default copy and paste according to cell value

How about changing that Y to some other character after it's copied to the other
sheet.

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim destCell As Range

With Worksheets("Daily")
Set myRng = .Range("O5:O92")
End With

For Each myCell In myRng.Cells
If LCase(myCell.Value) = "y" Then
With Worksheets("Funnel")
Set destCell = .Cells(.Rows.Count, "B").End(xlUp).Offset(1, 0)
End With
myrng.parent.Range(myCell.Offset(0, -1), myCell.Offset(0, -13)).Copy _
Destination:=destCell
mycell.value = "Copied" 'or just C????
End If
Next myCell
End Sub

"saman110 via OfficeKB.com" wrote:

I found this macro, but the problem is that it copies duplicates. for example
if I type "y" in column O5 and run the macro and then type "y" in O6 it will
copy previous row which is O5 again.

Any idea how to make it not to copy the previous row again?

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim destCell As Range

With Worksheets("Daily")
Set myRng = .Range("O5:O92")
End With

For Each myCell In myRng.Cells
If LCase(myCell.Value) = "y" Then
With Worksheets("Funnel")

Set destCell = .Cells(.Rows.Count, "B").End(xlUp).Offset(1, 0)

End With
Range(myCell.Offset(0, -1), myCell.Offset(0, -13)).Copy _
Destination:=destCell
End If
Next myCell
End Sub

saman110 wrote:
I'm looking for a macro that whenever I type "y" in "O" column it copy
corresponding cells from B:N to sheet 2 starting from B:5 and look for
another "y" in col. O and paste it below what it pasted before in sheet 2.

thx.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200801/1


--

Dave Peterson
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
How can I copy a value from a cell and paste it into another cell while adding it to the previous value in that cell [email protected] Excel Worksheet Functions 2 November 7th 07 09:39 AM
Want to use a Macro to copy and paste cell *value* only HeadRusch Excel Discussion (Misc queries) 1 May 11th 07 11:06 PM
how do i copy n paste one cell to another in different worksheets ucastores Excel Worksheet Functions 1 October 3rd 06 01:49 PM
Copy/Paste from once cell to another ebraun01 Excel Worksheet Functions 7 January 27th 06 09:30 PM
Select cell, Copy it, Paste it, Return to Previous cell spydor Excel Discussion (Misc queries) 1 December 30th 05 01:29 PM


All times are GMT +1. The time now is 06:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"