Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copying certain rows to another sheet

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Copying certain rows to another sheet

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copying certain rows to another sheet

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" wrote in message
oups.com...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Copying certain rows to another sheet

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
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 rows from one sheet to another.... Buyone Excel Worksheet Functions 1 June 20th 07 10:56 PM
copying rows from next sheet over ayl322 Excel Discussion (Misc queries) 3 November 22nd 05 07:39 PM
Automatically copying specified rows from a sheet to another Ossi Hannula Excel Programming 2 January 13th 05 02:21 AM
Copying rows to a new sheet Dave Excel Programming 4 September 9th 04 01:06 PM
Copying specific rows from one sheet to another Chris Excel Programming 2 October 17th 03 11:40 PM


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