Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
aledger
 
Posts: n/a
Default need a formula to copy entire row to next worksheet

If a cell contains the word Vice President I would like to copy the entire
row it sits on to the next worksheet. Is there a way to do this as a macro or
formula without using autofilter and copying the row manually?
  #2   Report Post  
Gord Dibben
 
Posts: n/a
Default

Is it likely that more than one cell contains the string "Vice President"?

Is it likely that string would be part of a larger string in the cell(s)?


Gord Dibben Excel MVP

On Fri, 4 Mar 2005 13:29:02 -0800, "aledger"
wrote:

If a cell contains the word Vice President I would like to copy the entire
row it sits on to the next worksheet. Is there a way to do this as a macro or
formula without using autofilter and copying the row manually?


  #3   Report Post  
Jef Gorbach
 
Posts: n/a
Default


"aledger" wrote in message
...
If a cell contains the word Vice President I would like to copy the entire
row it sits on to the next worksheet. Is there a way to do this as a macro

or
formula without using autofilter and copying the row manually?


Give this a try:

Sub Get_VP()
'copy column headings
Sheets("Sheet1").Rows(1).Copy Destination:=Sheets("Sheet2").Rows(1)
'find and copy Vice Presidential data rows to Sheet2
For RowIndex = 1 To ActiveSheet.UsedRange.Rows.Count
If Trim(UCase(Cells(RowIndex, 1).Value)) = "VICE PRESIDENT" Then
Sheets("Sheet1").Rows(RowIndex).Copy
Destination:=Sheets("Sheet2").Rows(RowIndex)
End If
Next RowIndex
'then eliminate the resulting blank lines between Vice President data from
above quick-n-dirty method
Sheets("Sheet2").Activate
For RowIndex = ActiveSheet.UsedRange.Rows.Count To 2 Step -1
If Cells(RowIndex, 1).Value = "" Then Rows(RowIndex).Delete
Next RowIndex
End Sub


  #4   Report Post  
aledger
 
Posts: n/a
Default

Jeff,
This formula is copying the first row to the next sheet. It's also not
filtering "Vice President." I don't have Vice President listed in any cell in
the first row. Do you think there is another formula or macro for this?

Thanks for your help.

"Jef Gorbach" wrote:


"aledger" wrote in message
...
If a cell contains the word Vice President I would like to copy the entire
row it sits on to the next worksheet. Is there a way to do this as a macro

or
formula without using autofilter and copying the row manually?


Give this a try:

Sub Get_VP()
'copy column headings
Sheets("Sheet1").Rows(1).Copy Destination:=Sheets("Sheet2").Rows(1)
'find and copy Vice Presidential data rows to Sheet2
For RowIndex = 1 To ActiveSheet.UsedRange.Rows.Count
If Trim(UCase(Cells(RowIndex, 1).Value)) = "VICE PRESIDENT" Then
Sheets("Sheet1").Rows(RowIndex).Copy
Destination:=Sheets("Sheet2").Rows(RowIndex)
End If
Next RowIndex
'then eliminate the resulting blank lines between Vice President data from
above quick-n-dirty method
Sheets("Sheet2").Activate
For RowIndex = ActiveSheet.UsedRange.Rows.Count To 2 Step -1
If Cells(RowIndex, 1).Value = "" Then Rows(RowIndex).Delete
Next RowIndex
End Sub



  #5   Report Post  
aledger
 
Posts: n/a
Default

You will only see Vice President in column C throughout various rows.

"Gord Dibben" wrote:

Is it likely that more than one cell contains the string "Vice President"?

Is it likely that string would be part of a larger string in the cell(s)?


Gord Dibben Excel MVP

On Fri, 4 Mar 2005 13:29:02 -0800, "aledger"
wrote:

If a cell contains the word Vice President I would like to copy the entire
row it sits on to the next worksheet. Is there a way to do this as a macro or
formula without using autofilter and copying the row manually?





  #6   Report Post  
Gord Dibben
 
Posts: n/a
Default

aledger

Might be just as easy to DataAutofilter for Vice President on Column C then
F5SpecialVisble Cells OnlyOK

Copy to next sheet.

Anyway.......macro as requested.

Sub Copy_Rows()
Dim RngCol As Range
Dim i As Range
Set RngCol = Range("C1", Range("C" & Rows.Count). _
End(xlUp).Address)
For Each i In RngCol
If i.Value = "Vice President" Then _
i.Rows.Copy Destination:=Sheets("Sheet2") _
.Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
Next i
End Sub


Gord

On Mon, 7 Mar 2005 10:53:09 -0800, "aledger"
wrote:

You will only see Vice President in column C throughout various rows.

"Gord Dibben" wrote:

Is it likely that more than one cell contains the string "Vice President"?

Is it likely that string would be part of a larger string in the cell(s)?


Gord Dibben Excel MVP

On Fri, 4 Mar 2005 13:29:02 -0800, "aledger"
wrote:

If a cell contains the word Vice President I would like to copy the entire
row it sits on to the next worksheet. Is there a way to do this as a macro or
formula without using autofilter and copying the row manually?




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
Howdo U copy a formula down a column, that uses data in another w. Need Help pasting a formula Excel Worksheet Functions 1 February 25th 05 06:04 PM
Howdo U copy a formula down a column, that uses data in another w. brantty Excel Worksheet Functions 0 February 25th 05 10:11 AM
How do you copy a formula without incrementing some constants? JohnT Excel Worksheet Functions 2 February 18th 05 11:09 AM
How do you copy a cell formula down a column without displaying n. Coddie Excel Worksheet Functions 4 January 18th 05 02:31 PM
Copy a Formula down with a Twist Q John Excel Worksheet Functions 7 November 23rd 04 10:03 PM


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

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"