Hello,
I'm really sorry to bother everyone.
I am stuck with writing a complex macro and have been searching google for about a week and I've noticed many people come to this board and get assistance, so I too have come in search of help.
I am very new to VBA but I am trying to learn to improve excel based jobs at work. I have written a few very simple macros successfully so have very basic knowledge.
I am currently doing something with Autofilter, that works fine but the spreadsheet usually contains thousands of rows and I'm trying to write a macro to automate this to be quick and efficient.
I have one sheet of "master data" that I am filtering and copying to new sheets based on the filter criteria.
What I'm trying to do is this:
[TABLE="width: 505"]
<tbody>[TR]
[TD]Header1[/TD]
[TD]Header2[/TD]
[TD]Header3[/TD]
[TD]Header4[/TD]
[TD]Header5[/TD]
[TD]BF[/TD]
[/TR]
[TR]
[TD]UNKNOWNS[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF1 TEXTHERE[/TD]
[/TR]
[TR]
[TD]UNKNOWNS[/TD]
[TD]PV[/TD]
[TD]Placeholder2[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF2 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]Placeholder3[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF3 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]Placeholder4[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF4 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]Placeholder4[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF7 TEXTHERE[/TD]
[/TR]
[TR]
[TD]UNKNOWNS[/TD]
[TD]PV[/TD]
[TD]Placeholder4[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF1 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]Placeholder4[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF1 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]Placeholder4[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF3 TEXTHERE[/TD]
[/TR]
[TR]
[TD]UNKNOWNS[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF4 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF4 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF7 TEXTHERE[/TD]
[/TR]
[TR]
[TD]UNKNOWNS[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF3 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF4 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF3 TEXTHERE[/TD]
[/TR]
</tbody>[/TABLE]
Above is an example sheet. I can't use the actual data as it's financial. The main filter criteria is the last column filtering for starts with BFX. X going from 1-52 (which represents weeks). I also want to pull out rows that contain certain text strings from other columns, eg. the unknowns in A and the placeholders in C. I've filled the other spaces with PV for placeholder value.
I have tried recording what I do but I don't think this helps me much as I don't know how to get it to "loop?" for every filter criteria, BF1*, BF2*, etc.
What I need help with is how to target the column of data and search for a particular string. I've tried INSTR but I can't get it to work at all when I try to target cells or ranges. I also need it to check through every cell in the column and copy everything that starts with the filter criteria.
I found this thread: http://www.mrexcel.com/forum/excel-...-copy-rows-based-criteria-new-sheet-file.html - While it seems to have the same sort of idea, I don't want only unique values, I want every row but sorted into the right sheet. I think that's the right lines but I don't know how to tweak it.
I also found this: http://www.mrexcel.com/forum/excel-...s-move-rows-another-sheet-based-criteria.html which does exactly what I want but only for 3 variables and they are exact as a pose to my partial text strings in a larger text string.
I'm really sorry for the long first post and I hope I conveyed what I meant concisely. I would greatly appreciate any assistance.
Thank you.
I'm really sorry to bother everyone.
I am stuck with writing a complex macro and have been searching google for about a week and I've noticed many people come to this board and get assistance, so I too have come in search of help.
I am very new to VBA but I am trying to learn to improve excel based jobs at work. I have written a few very simple macros successfully so have very basic knowledge.
I am currently doing something with Autofilter, that works fine but the spreadsheet usually contains thousands of rows and I'm trying to write a macro to automate this to be quick and efficient.
I have one sheet of "master data" that I am filtering and copying to new sheets based on the filter criteria.
What I'm trying to do is this:
- Filter the data (via either autofilter or advanced filter) by around 60 different criteria. 50+ of the filters are on the same column (F).
- I'd like the macro to create a sheet with the same name as the filter criteria if it returns results. I have not yet found a way to do this, would the best way to be to create all the possible sheets I need and run code to delete the blanks?
- Copy the filtered data to the corresponding created sheet.
- Finally, I'd like the macro to fill the data it has copied in sheet 1 yellow, so that I can sweep up any that haven't been copied by using Autofilter by fill. This was also useful for when I was doing it manually to prevent me making duplicates. There will inevitably be anomolyous rows that don't have the proper text in them to filter so it would be easy for me to sweep these up manually if the copied data was filled on the master sheet.
[TABLE="width: 505"]
<tbody>[TR]
[TD]Header1[/TD]
[TD]Header2[/TD]
[TD]Header3[/TD]
[TD]Header4[/TD]
[TD]Header5[/TD]
[TD]BF[/TD]
[/TR]
[TR]
[TD]UNKNOWNS[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF1 TEXTHERE[/TD]
[/TR]
[TR]
[TD]UNKNOWNS[/TD]
[TD]PV[/TD]
[TD]Placeholder2[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF2 TEXTHERE[/TD]
[/TR]
[TR]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]Placeholder3[/TD]
[TD]PV[/TD]
[T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[TD]PV[/TD]
[TD]PV[/TD]
[TD]PV[/TD]
[TD]BF3 TEXTHERE[/TD]
[/TR]
</tbody>[/TABLE]
Above is an example sheet. I can't use the actual data as it's financial. The main filter criteria is the last column filtering for starts with BFX. X going from 1-52 (which represents weeks). I also want to pull out rows that contain certain text strings from other columns, eg. the unknowns in A and the placeholders in C. I've filled the other spaces with PV for placeholder value.
I have tried recording what I do but I don't think this helps me much as I don't know how to get it to "loop?" for every filter criteria, BF1*, BF2*, etc.
What I need help with is how to target the column of data and search for a particular string. I've tried INSTR but I can't get it to work at all when I try to target cells or ranges. I also need it to check through every cell in the column and copy everything that starts with the filter criteria.
I found this thread: http://www.mrexcel.com/forum/excel-...-copy-rows-based-criteria-new-sheet-file.html - While it seems to have the same sort of idea, I don't want only unique values, I want every row but sorted into the right sheet. I think that's the right lines but I don't know how to tweak it.
I also found this: http://www.mrexcel.com/forum/excel-...s-move-rows-another-sheet-based-criteria.html which does exactly what I want but only for 3 variables and they are exact as a pose to my partial text strings in a larger text string.
I'm really sorry for the long first post and I hope I conveyed what I meant concisely. I would greatly appreciate any assistance.
Thank you.