PC Review


Reply
Thread Tools Rate Thread

Copying certain rows to another sheet

 
 
Bob
Guest
Posts: n/a
 
      5th Oct 2007
Hi,
I'm hoping someone can help me with this problem.
I have 5 sheets of information all in one workbook.
All identical set up.
Column A - Name -
Column B - Company
Column C - Current - marked with a "c" if record is current.
Other columns over to column T with various numerical values but could be
blank.

I want to go to Sheet 1 and filter the list by the "c" in column C
Then I want to copy only the visible cells in columns A to T and starting at
row 7
And stopping at the first blank row

Then move to a 6th sheet called "Current" and paste the copied data

I then want to move to Sheet 2 and filter the list by the "c" in column C
Copy only the visible cells
Then move to the 6th sheet called Current

Find the first blank row under what was pasted previously and paste the
copied data

And so on for 5 sheets.

I can easily do it manually with AutoFilter and Go To > Visible Cells Only
tools but I need to be able to get it done with the click of 1 button.

I'm OK at understanding and adapting code but I'm just a beginner at writing
it from scratch.

Thanks

Bob


 
Reply With Quote
 
 
 
 
marcus
Guest
Posts: n/a
 
      5th Oct 2007
Hi Bob

I hope I have understood correctly. This code filters data on
criteria in Column 3 with criteria of "C", then copies the data to the
first non blank cell in the Current sheet. I hope this helps, you
should be able to manipulate it as you wish. Good luck.

Marcus

Sub CopytoSheet()

Dim s As Worksheet
Dim x As Long
Dim y As Long

For Each s In Sheets
If s.Name <> "Current" Then
s.Activate
s.AutoFilterMode = False
'Check for filter on page.
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Rows("7:7").AutoFilter
End If
Selection.AutoFilter Field:=3, Criteria1:="C" ' filter criteria
y = Range("a65536").End(xlUp).Row + 1
Range("A8:T" & y).Copy
Sheets("Current").Select
x = Range("A65536").End(xlUp).Row + 1
Range("A" & x).Select
ActiveSheet.Paste

End If
Next
End Sub

 
Reply With Quote
 
Bob
Guest
Posts: n/a
 
      5th Oct 2007
Thats perfect, thanks Marcus

I had to change a few minor things because its so hard to explain exactly
whats required without writing pages, but I really had no idea where to
start.

I added some nested If's because there are actually some other sheets in the
workbook

For Each s In Sheets
If s.Name <> "Current" Then
If s.Name <> "Clients" Then
If s.Name <> "FILTER" Then

Thanks again

Bob

"marcus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Bob
>
> I hope I have understood correctly. This code filters data on
> criteria in Column 3 with criteria of "C", then copies the data to the
> first non blank cell in the Current sheet. I hope this helps, you
> should be able to manipulate it as you wish. Good luck.
>
> Marcus
>
> Sub CopytoSheet()
>
> Dim s As Worksheet
> Dim x As Long
> Dim y As Long
>
> For Each s In Sheets
> If s.Name <> "Current" Then
> s.Activate
> s.AutoFilterMode = False
> 'Check for filter on page.
> If Not ActiveSheet.AutoFilterMode Then
> ActiveSheet.Rows("7:7").AutoFilter
> End If
> Selection.AutoFilter Field:=3, Criteria1:="C" ' filter criteria
> y = Range("a65536").End(xlUp).Row + 1
> Range("A8:T" & y).Copy
> Sheets("Current").Select
> x = Range("A65536").End(xlUp).Row + 1
> Range("A" & x).Select
> ActiveSheet.Paste
>
> End If
> Next
> End Sub
>



 
Reply With Quote
 
marcus
Guest
Posts: n/a
 
      5th Oct 2007
Hi Bob

Pleased to be of assistance. You kept your question short and to the
point.

You can reduce your IF statements futher by using this code.

If (s.Name) <> "Current" And (s.Name) <> "Clients" And (s.Name) <>
"FILTER" Then

Take care

Marcus

 
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
Copying rows values on one sheet to part of a formula in a column onanother sheet. Manosh Microsoft Excel Discussion 2 23rd Jun 2009 03:58 AM
Copying rows from one sheet to another.... =?Utf-8?B?QnV5b25l?= Microsoft Excel Worksheet Functions 1 20th Jun 2007 10:56 PM
Help copying rows and arranging in new sheet flurry Microsoft Excel Programming 5 10th May 2006 06:54 PM
copying rows from next sheet over ayl322 Microsoft Excel Misc 3 22nd Nov 2005 07:39 PM
Copying rows to a new sheet Dave Microsoft Excel Programming 4 9th Sep 2004 01:06 PM


Features
 

Advertising
 

Newsgroups
 


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