Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Loop through sheets & filter main sheet using sheet name

Hello all, as i am not a programmer i am battling with the following...
I have a wkb with the main sheet "Hauptseite-1" in this sheet i have a
variable amount of rows with the names of the responsible person in column
"O". I have created a sheet for each name & the sheet is named with the
applicable name.
I now need to loop through all sheets, with the exception of "Hauptseite-1"
and filter column "O" on the sheet "Hauptseite-1" using the sheet Names as
the filter criteria, copy the data found and past it onto the respective
sheet.

I would be very gratefull for any help.
--
Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Loop through sheets & filter main sheet using sheet name

Not sure where you want to paste the data. I wrote the data to the entire
sheet.

Sub FilterDate()


For Each sht In ThisWorkbook.Sheets
If sht.Name < "Hauptseite-1" Then
With Sheets("Hauptseite-1")
If .FilterMode = True Then
.ShowAllData
End If
Columns("O").AutoFilter field:=1, Criteria1:=sht.Name
.Cells.SpecialCells(xlCellTypeVisible).Copy _
Destination:=sht.Cells
End With
End If
Next sht
If Sheets("Hauptseite-1").FilterMode = True Then
Sheets("Hauptseite-1").ShowAllData
End If
End Sub

"Les" wrote:

Hello all, as i am not a programmer i am battling with the following...
I have a wkb with the main sheet "Hauptseite-1" in this sheet i have a
variable amount of rows with the names of the responsible person in column
"O". I have created a sheet for each name & the sheet is named with the
applicable name.
I now need to loop through all sheets, with the exception of "Hauptseite-1"
and filter column "O" on the sheet "Hauptseite-1" using the sheet Names as
the filter criteria, copy the data found and past it onto the respective
sheet.

I would be very gratefull for any help.
--
Les

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Loop through sheets & filter main sheet using sheet name

Hi Les,

It might be easier if you copy the rows you want into the named spreadsheets
rather than copy all rows and filter them.


I'm free-typing this so you'll need to de-bug it.

Sub demo()

dim ws as worksheet
dim s as string
dim i as integer
dim j as integer

for each ws in worksheets
if not ws.name = "Hauptseite-1" then
s = ws.name
do until isempty(worksheets("Hauptseite-1").range("o2").offset(i,0))
if worksheets("Hauptseite-1").range("o2").offset(i,0).value = s then
worksheets("Hauptseite-1").range("o2").offset(i,0).entirerow.copy
ws.range("a1").offset(j,0).entirerow.paste
j=j+1
end if
i=i+1
loop
end if
i=0
j=0
next ws




end sub


"Les" wrote:

Hello all, as i am not a programmer i am battling with the following...
I have a wkb with the main sheet "Hauptseite-1" in this sheet i have a
variable amount of rows with the names of the responsible person in column
"O". I have created a sheet for each name & the sheet is named with the
applicable name.
I now need to loop through all sheets, with the exception of "Hauptseite-1"
and filter column "O" on the sheet "Hauptseite-1" using the sheet Names as
the filter criteria, copy the data found and past it onto the respective
sheet.

I would be very gratefull for any help.
--
Les

  #4   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Loop through sheets & filter main sheet using sheet name

Hi Joel, it is copying to the correct sheet, but need the filter in row 11
and need to copy from A11 and all data.

Thanks you for the help

--
Les


"Joel" wrote:

Not sure where you want to paste the data. I wrote the data to the entire
sheet.

Sub FilterDate()


For Each sht In ThisWorkbook.Sheets
If sht.Name < "Hauptseite-1" Then
With Sheets("Hauptseite-1")
If .FilterMode = True Then
.ShowAllData
End If
Columns("O").AutoFilter field:=1, Criteria1:=sht.Name
.Cells.SpecialCells(xlCellTypeVisible).Copy _
Destination:=sht.Cells
End With
End If
Next sht
If Sheets("Hauptseite-1").FilterMode = True Then
Sheets("Hauptseite-1").ShowAllData
End If
End Sub

"Les" wrote:

Hello all, as i am not a programmer i am battling with the following...
I have a wkb with the main sheet "Hauptseite-1" in this sheet i have a
variable amount of rows with the names of the responsible person in column
"O". I have created a sheet for each name & the sheet is named with the
applicable name.
I now need to loop through all sheets, with the exception of "Hauptseite-1"
and filter column "O" on the sheet "Hauptseite-1" using the sheet Names as
the filter criteria, copy the data found and past it onto the respective
sheet.

I would be very gratefull for any help.
--
Les

  #5   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Loop through sheets & filter main sheet using sheet name

Thanks Sam, i think the quickest way would be best...

Not sure which one that would be ??

--
Les


"Sam Wilson" wrote:

Hi Les,

It might be easier if you copy the rows you want into the named spreadsheets
rather than copy all rows and filter them.


I'm free-typing this so you'll need to de-bug it.

Sub demo()

dim ws as worksheet
dim s as string
dim i as integer
dim j as integer

for each ws in worksheets
if not ws.name = "Hauptseite-1" then
s = ws.name
do until isempty(worksheets("Hauptseite-1").range("o2").offset(i,0))
if worksheets("Hauptseite-1").range("o2").offset(i,0).value = s then
worksheets("Hauptseite-1").range("o2").offset(i,0).entirerow.copy
ws.range("a1").offset(j,0).entirerow.paste
j=j+1
end if
i=i+1
loop
end if
i=0
j=0
next ws




end sub


"Les" wrote:

Hello all, as i am not a programmer i am battling with the following...
I have a wkb with the main sheet "Hauptseite-1" in this sheet i have a
variable amount of rows with the names of the responsible person in column
"O". I have created a sheet for each name & the sheet is named with the
applicable name.
I now need to loop through all sheets, with the exception of "Hauptseite-1"
and filter column "O" on the sheet "Hauptseite-1" using the sheet Names as
the filter criteria, copy the data found and past it onto the respective
sheet.

I would be very gratefull for any help.
--
Les

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
Main sheet automatically picks up data from other sheets Max Excel Worksheet Functions 14 February 13th 09 07:42 AM
Updating sheets in Workbook from main sheet IMS Lori Excel Discussion (Misc queries) 0 January 28th 08 07:11 PM
LINKING MAIN SHEET WITH MULTIPLE SUMMARY SHEETS SSJ New Users to Excel 2 July 9th 07 03:13 AM
LINKING MAIN SHEET WITH MULTIPLE SUMMARY SHEETS SSJ Excel Worksheet Functions 2 July 9th 07 03:13 AM
How do I combine data from several sheets into one main sheet? Caren F Excel Worksheet Functions 0 April 19th 06 06:39 PM


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