Hi - as per title, could someone advise me how to do this please? Basically, I have a report that I use everyweek and split up into various sheets according to the criteria.
So if any cell in column C contains "Apple", then I want it copied into a new s/s (with the headers). I basically have to do a number of iterations on this, can someone assist please? The main problem I invisage is asking Excel to copy the row into the new sheet underneath the last one.
Many thanks, Jimmy.
You could try filtering on column C and manually copying and pasting the data into a new spreadsheet
Regards
Special-K
I rarely return to a problem once I've answered it so make sure you clearly define what the trouble is.
Right, that's what I'm doing now. But I'm trying to get the vba coding in, to avoid the manual work.
Need to clarify something.
Is this a conditional behavior, ie. copy row to a new sheet IF certain criteria are met.
Or do you have several rows worth of information which you would like new sheets made, with the headers of each being named after that row's name.
=IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)
Conditional Behaviour. So firstly each sheet will carry the same set of headers.
Then, if any cell in Column B contains "Apple", then the entire row needs to be copied into Sheet2 (one underneath each other after the header). If any cell in Column B contains "Orange", then the entire row needs to be copied into Sheet3, etc etc. I have a series of these I need to do.
Thanks for any help.
An example workbook would be invaluable at this point.
I *think* that you want to go through all of column b, and for every cell that has a corresponding worksheet with the same name, add that information to the next empty row of that worksheet. If there is NOT a corresponding worksheet, do you want a new one made to suit, and continue on from there?
Last edited by mewingkitty; 04-20-2009 at 09:41 AM.
=IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)
Here you go, so basically Sheet 1 is a mock-up of my extracted data. And the resulting three tabs are what I'd like generated from the macro (the Sheets are always pre-defined - or at least will be when I write the vba code).
Here is an invaluable piece of code I frequently use. I take no credit for its existence.
It doesn't do your job quite how you describe. Though it will split a database into sheets by column A. Either copy your column B to A, or change the code. So where it says A1, change to B1.
I'm sure you'll get a perfect solution shortly; knowledge is abundant around here.
Sub PagesByDescription() Dim rRange As Range, rCell As Range Dim wSheet As Worksheet Dim wSheetStart As Worksheet Dim strText As String Set wSheetStart = ActiveSheet wSheetStart.AutoFilterMode = False 'Set a range variable to the correct item column Set rRange = Range("A1", Range("A65536").End(xlUp)) 'Delete any sheet called "UniqueList" 'Turn off run time errors & delete alert On Error Resume Next Application.DisplayAlerts = False Worksheets("UniqueList").Delete 'Add a sheet called "UniqueList" Worksheets.Add().Name = "UniqueList" 'Filter the Set range so only a unique list is created With Worksheets("UniqueList") rRange.AdvancedFilter xlFilterCopy, , _ Worksheets("UniqueList").Range("A1"), True 'Set a range variable to the unique list, less the heading. Set rRange = .Range("A2", .Range("A65536").End(xlUp)) End With On Error Resume Next With wSheetStart For Each rCell In rRange strText = rCell .Range("A1").AutoFilter 1, strText Worksheets(strText).Delete 'Add a sheet named as content of rCell Worksheets.Add().Name = strText 'Copy the visible filtered range _ 'default of Copy Method) and leave hidden rows .UsedRange.Copy Destination:=ActiveSheet.Range("A1") ActiveSheet.Cells.Columns.AutoFit Next rCell End With With wSheetStart .AutoFilterMode = False .Activate End With On Error GoTo 0 Application.DisplayAlerts = True End Sub
Okies right on, we're on the same page.
See attached file.
If the sheet name is going to have "my" at the beginning of it, you could modify the code to read from a mid of 2 to the end, that'd match it to everything after your "my". Currently it looks for exact text matches, and copies over the corresponding data. If no such sheet exists, it moves on.
=IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)
Hi - thanks for the help. The reason I wrote them as "MyOranges" is because the sheet name isn't going to be whatever the criteria of the cell is. They will take on pre-defined names which I can write into the VBA code pretty easily.
Also, am I going mad, or is there no code attached to the file lol?
You're going mad.Option Explicit Private Sub CommandButton1_Click() Dim wks As Worksheet Dim x As Integer Dim y As Integer Dim z As Integer x = 1 y = 2 z = 1 Do While Cells(x, 2) <> vbNullString x = x + 1 y = 2 z = 1 For Each wks In Worksheets If UCase(Cells(x, 2)) = UCase(wks.Name) Then Do While Worksheets(wks.Name).Cells(y, 2) <> vbNullString y = y + 1 Loop Do While Cells(x, z) <> vbNullString Worksheets(wks.Name).Cells(y, z) = Cells(x, z) z = z + 1 Loop End If Next wks Loop End Sub
:D
When in design mode, double click on the command button,
or alternatively, just click on the "Visual Basic" button on the top left of the developer tab.
Let me know if you can work with that or if we need to go another direction.
=IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)
Sounds like something more along the lines of the attached file may be what you're after.
There are all kinds of ways to go about this. You could even have it pop up three boxes asking for the criteria for page one, then two, then three, and have it run the search from there.
There's still al lot I don't know about how you want this to work. Do you want to clear the three targets each time a search is run, or would you like it to check for duplicates..? At the moment if you keep clicking the button, it'll keep adding to the list.
=IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)
Or to eliminate the need to hop back into the code every time:
=IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)
Hi,
I am trying to do something very similar. If you look at the attached spreadsheet you will see 6 tabs. Main, New Cust, Quote, etc.
"Main" will be the sheet that everything is inputted. If there is a "Y" under new customer, I want the entire row to copy to the tab "New Cust". If there is an "X" under quote, struct design, or graphic design I want it under its approp. tab. The Lisa tab should take certain Sales-Person and copy entire row on the Lisa tab. The certain Sales-Persons are BS, PK, PB, PD.
Any help will be greatly appreciated.
sry, haven't been on in a while.
Please explain when you want it to update. Could make it re-copy them all every time you changed which cell is active, but that's going to slow your sheet down a lot.
Personally I like buttons. I'd make it so that you check off/uncheck whatever you want and then have a button you press to run the update.
So, what's the plan.
=IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks