Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Copying row using if function

Hi all

How do I want to select all the entire rows with the name yes from sheet
1and get them pasted on to sheet 2

How do you suggest to do this

TIA

Greg


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Copying row using if function

Greg,

If your "yes" values are in the first column of a table starting in cell A1
on Sheet1, then

Sheets("Sheet1").Range("A1").AutoFilter _
Field:=1, Criteria1:="Yes"
Sheets("Sheet1").Range("A1").CurrentRegion.Special Cells _
(xlCellTypeVisible).Copy _
Sheets("Sheet2").Range("A1")

HTH,
Bernie
MS Excel MVP

"Greg B..." wrote in message
...
Hi all

How do I want to select all the entire rows with the name yes from sheet
1and get them pasted on to sheet 2

How do you suggest to do this

TIA

Greg




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying row using if function

Assume Yes or no is in column 3
Sub CopyData()
Dim rng as Range, cell as Range, col as Long
Dim rw as Long
col = 3
rw = 2
With Worksheets("sheet1")
set rng = .range(.cells(2,col),.cells(rows.count,col).End(xl up))
End with
for each cell in rng
if lcase(cell.value) = "yes" then
cell.EntireRow.copy Destination:=worksheets("sheet2") _
.cells(rw,1)
rw = rw + 1
end if
Next
End Sub

There are certainly faster ways to do it, but this should work and should be
easy to understand.

--
Regards,
Tom Ogilvy
"Greg B..." wrote in message
...
Hi all

How do I want to select all the entire rows with the name yes from sheet
1and get them pasted on to sheet 2

How do you suggest to do this

TIA

Greg




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Copying row using if function

Sorry to be a pain again

I tried to make it easier to understand but I have now totally confused
myself again.

What I tried to do is a if function where if the date of the entry is more
than 2 years old mark it as yes.

Then I wanted a control to copy all the yes answers and place then on sheet
2 here is a diagram

date comment
21 feb 2002 back from school yes <- this will be hidden in white
text.

I want it to the copy from sheet 1 to sheet 2 and delete the entry from
sheet 1.

I am sorry to be such a pain but I am struggling with this vba language.

Greg


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying row using if function

Sub CopyData()
Dim rng as Range, cell as Range, col as Long
Dim rw as Long, rng2 as Range
col = 3
rw = 2
With Worksheets("sheet1")
set rng = .range(.cells(2,col),.cells(rows.count,col).End(xl up))
End with
for each cell in rng
if lcase(cell.value) = "yes" then
cell.EntireRow.copy Destination:=worksheets("sheet2") _
.cells(rw,1)
rw = rw + 1
if rng2 is nothing then
set rng2 = cell
else
set rng2 = union(rng2,cell)
end if
end if
Next
if not rng2 is nothing then
rng2.EntireRow.Delete
End if
End Sub

--
Regards,
Tom Ogilvy

"Greg B..." wrote in message
...
Sorry to be a pain again

I tried to make it easier to understand but I have now totally confused
myself again.

What I tried to do is a if function where if the date of the entry is more
than 2 years old mark it as yes.

Then I wanted a control to copy all the yes answers and place then on

sheet
2 here is a diagram

date comment
21 feb 2002 back from school yes <- this will be hidden in

white
text.

I want it to the copy from sheet 1 to sheet 2 and delete the entry from
sheet 1.

I am sorry to be such a pain but I am struggling with this vba language.

Greg






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Copying row using if function

Thankyou Tom

Sorry for the late reply Is there a chance to have that formula insert the
new cells above the previous entries

It does everything but copies over the top

Thanks in advance

Greg


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying row using if function

A later post indicates you solved it.

--
Regards,
Tom Ogilvy

"Greg B..." wrote in message
...
Thankyou Tom

Sorry for the late reply Is there a chance to have that formula insert the
new cells above the previous entries

It does everything but copies over the top

Thanks in advance

Greg




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
copying the Hyperlink function result without copying the actual formula mcheng Excel Worksheet Functions 2 June 9th 07 02:43 AM
Enable copying function Freshman Excel Worksheet Functions 5 November 15th 06 07:42 PM
copying function value Miss Dedly Excel Discussion (Misc queries) 2 January 12th 06 07:58 PM
copying existing function Brad Excel Worksheet Functions 0 February 22nd 05 01:34 PM
Function not copying ppsza[_6_] Excel Programming 2 May 9th 04 12:06 PM


All times are GMT +1. The time now is 04:59 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"