Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Find Specific Rows in Range and Create New Tab

Hello all,
I have a sorting issue I hope someone can assist with. I have a “roll up” sheet that combines data from numerous tabs. All the tabs have the exact same headers as well as the roll up. The header range is A18:Z18 and the data starts directly below in row 19. The header in column E (called Job#) is what I need to sort by. There are numerous job numbers and are not in any particular order.

I am in need of a macro that will search the Job# column, find all the rows with that specific job number, insert a new sheet, rename the sheet the "Job" and job number, and then populate the headers and the cell references (not copy, since I need to keep the references to the roll up). It would also be good if the macro could sort by the names in column A, but is not necessary.

For example, in the “roll up” there are 100 rows with 20 unique job numbers (column E). Job number 5555 shows up 30 times in the table with no real pattern. I would like the macro to find all 30 rows for job 5555, then open a new tab, rename the tab “Job 5555” and populate the tab with the all the headers (and in row 18 as well) and the cell references from the master directly below the headers. Once complete, it moves on to the next job number and repeats until all unique job numbers have their own sheets.

Any feedback would be fantastic. Thank you in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Find Specific Rows in Range and Create New Tab

Hi,

Am Thu, 24 Oct 2013 11:35:53 -0700 (PDT) schrieb excelnoob:

I have a sorting issue I hope someone can assist with. I have a ?roll up? sheet that combines data from numerous tabs. All the tabs have the exact same headers as well as the roll up. The header range is A18:Z18 and the data starts directly below in row 19. The header in column E (called Job#) is what I need to sort by. There are numerous job numbers and are not in any particular order.

I am in need of a macro that will search the Job# column, find all the rows with that specific job number, insert a new sheet, rename the sheet the "Job" and job number, and then populate the headers and the cell references (not copy, since I need to keep the references to the roll up). It would also be good if the macro could sort by the names in column A, but is not necessary.

For example, in the ?roll up? there are 100 rows with 20 unique job numbers (column E). Job number 5555 shows up 30 times in the table with no real pattern. I would like the macro to find all 30 rows for job 5555, then open a new tab, rename the tab ?Job 5555? and populate the tab with the all the headers (and in row 18 as well) and the cell references from the master directly below the headers. Once complete, it moves on to the next job number and repeats until all unique job numbers have their own sheets.


try:

Sub Test()
Dim LRow As Long
Dim LrowT As Long
Dim rngC As Range
Dim varFilter() As Variant
Dim i As Integer

Application.ScreenUpdating = False
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "Temp"
With Sheets("RollUp")
LRow = .Cells(Rows.Count, "E").End(xlUp).Row
.Range("E18:E" & LRow).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("A1"), Unique:=True

LrowT = Sheets("Temp").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To LrowT
ReDim Preserve varFilter(LrowT - 2)
varFilter(i - 2) = Sheets("Temp").Cells(i, 1)
Next

With .Range("A18:Z" & LRow)
For i = LBound(varFilter) To UBound(varFilter)
.AutoFilter field:=5, Criteria1:=varFilter(i)
.Copy
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "Job " & varFilter(i)
[A18].Select
ActiveSheet.Paste link:=True
ActiveSheet.UsedRange.Sort key1:=Range("A18"), _
Order1:=xlAscending, Header:=xlYes
Next
End With
..AutoFilterMode = False
End With
Application.DisplayAlerts = False
Sheets("Temp").Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Find Specific Rows in Range and Create New Tab

Hello Claus,
Thank you for such a quick response. The macro works as it should for the most part, however after using it, I just realized I may need to take it a slightly different direction.
Instead of having it create a new tab for each sort, I need to have it pull from a template called "JobTemp". I start the headers on row 18 as the section above is used for additional information for each job.

Would it be possible to use JobTemp as the start sheet for all the "Job xxxx" sheets?

Also, the formatting seems to be off. It wants to bring in the "date" format for almost all the columns. I have tried changing the formatting of the source data, but to no avail. Any feedback helps. Thank you again.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Find Specific Rows in Range and Create New Tab

Hi,

Am Thu, 24 Oct 2013 14:11:54 -0700 (PDT) schrieb excelnoob:

Thank you for such a quick response. The macro works as it should for the most part, however after using it, I just realized I may need to take it a slightly different direction.
Instead of having it create a new tab for each sort, I need to have it pull from a template called "JobTemp". I start the headers on row 18 as the section above is used for additional information for each job.

Would it be possible to use JobTemp as the start sheet for all the "Job xxxx" sheets?

Also, the formatting seems to be off. It wants to bring in the "date" format for almost all the columns. I have tried changing the formatting of the source data, but to no avail. Any feedback helps. Thank you again.


try:

Sub Test()
Dim LRow As Long
Dim LrowT As Long
Dim rngC As Range
Dim varFilter() As Variant
Dim i As Integer

Application.ScreenUpdating = False
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "Temp"
With Sheets("JobTemp")
LRow = .Cells(Rows.Count, "E").End(xlUp).Row
.Range("E18:E" & LRow).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("A1"), Unique:=True

LrowT = Sheets("Temp").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To LrowT
ReDim Preserve varFilter(LrowT - 2)
varFilter(i - 2) = Sheets("Temp").Cells(i, 1)
Next

With .Range("A18:Z" & LRow)
For i = LBound(varFilter) To UBound(varFilter)
.AutoFilter field:=5, Criteria1:=varFilter(i)
.Copy
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "Job " & varFilter(i)
[A18].Select
ActiveSheet.Paste link:=True
ActiveSheet.Range("A18").PasteSpecial xlPasteFormats
ActiveSheet.UsedRange.Sort key1:=Range("A18"), _
Order1:=xlAscending, Header:=xlYes
Next
End With
..AutoFilterMode = False
End With
Application.DisplayAlerts = False
Sheets("Temp").Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Find Specific Rows in Range and Create New Tab

Hello Claus,
I think it is getting closer, however I am getting an error with the 12th line down

.Range("E18:E" & LRow).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("A1"), Unique:=True

For some reason it does not like this code now. My JobTemp tab does have some data and formulas above the header (rows 1-18 with the header in row 18). However when I clear all the info and headers from the JobTemp tab, it seems to work, however I get another error with this line of code.

For i = LBound(varFilter) To UBound(varFilter)

Ultimately, I would like to have whatever I need in rows 1-18 on the JobTemp tab as I know this will change in the future.

Thank you again for your support.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Find Specific Rows in Range and Create New Tab

Hi,

Am Fri, 25 Oct 2013 07:40:00 -0700 (PDT) schrieb excelnoob:

.Range("E18:E" & LRow).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("A1"), Unique:=True

For some reason it does not like this code now. My JobTemp tab does have some data and formulas above the header (rows 1-18 with the header in row 18). However when I clear all the info and headers from the JobTemp tab, it seems to work, however I get another error with this line of code.


my suggestions are always tested and are working. Did you change
anything in the code?
First a new sheet "Temp" will be created and all job numbers will be
copied as unique numbers to this sheet. Only if this sheet exists the
filter array varFilter can be filled. At the end of the code this sheet
"Temp" will be deleted.


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
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
how do I find all the rows containing a specific value in excel MadProphet Excel Programming 1 March 23rd 10 01:17 PM
How do i create a macro to find a specific data? James Excel Programming 2 March 14th 06 07:56 AM
how to create a formula to hide specific rows after meeting requi DNelson New Users to Excel 2 February 7th 06 01:06 PM
create named range specific to worksheet [email protected] Excel Programming 2 June 28th 05 04:38 PM
Can I create a formula to find a specific value within a group of. nccpa13 Excel Worksheet Functions 2 March 8th 05 02:05 PM


All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"