I've come accross a particular need to be able to filter a column in Excel by the format. The specific problem consists of a field that is populated with various types of personal information from various consumers. It for a report showing what employees searched for with a particular application.
The current report only gives us what that person searched for. For instance, Agent Smith might have searched for "123 Main St", whereas Agent Jones might have searched for "123-45-6789", and Agent Miller searched for "555-555-1212" just as some examples as to the actual data in that column.
What I would like to do (and I can import it into Access if that would make it simpler) is to split all of this out into separate Excel Spreadsheets (or tables/queries in Access) based on what type of information is in that field.
I was not sure of a way to do this in Excel with an autofilter (it is possible that I just overlooked it, or am just not aware of the particular method, as of yet). So, I thought I could come up with a VBA method to loop through the cells in the one column, and based on the findings for each column, copy that record to the appropriate spreadsheet.
So, what I would want to eventually have (in whatever is the best format - Excel, Access, SQL, whatever) is probably up to 5 or 6 different files, and each would be for a different search criteria. One would be address, one = SSN, and one = telephone (there are a few others, but I think I can just take care of those rather easily, based on a different field).
I have done some VBA in Excel (haven't done much in the past year or so), but I can't think of what would be the best way to check for specific formatting in the cells. I am sure there is a way, and there may be an altogether better method than I am currently dealing with.
Here is what I've gotten started with so far:
Of course, the error handling and every detail has not been worked out yet, but I'm trying to get the idea down pat before I worry about the extras.
Any suggestions would be greatly appreciated. Thanks in advance.
The current report only gives us what that person searched for. For instance, Agent Smith might have searched for "123 Main St", whereas Agent Jones might have searched for "123-45-6789", and Agent Miller searched for "555-555-1212" just as some examples as to the actual data in that column.
What I would like to do (and I can import it into Access if that would make it simpler) is to split all of this out into separate Excel Spreadsheets (or tables/queries in Access) based on what type of information is in that field.
I was not sure of a way to do this in Excel with an autofilter (it is possible that I just overlooked it, or am just not aware of the particular method, as of yet). So, I thought I could come up with a VBA method to loop through the cells in the one column, and based on the findings for each column, copy that record to the appropriate spreadsheet.
So, what I would want to eventually have (in whatever is the best format - Excel, Access, SQL, whatever) is probably up to 5 or 6 different files, and each would be for a different search criteria. One would be address, one = SSN, and one = telephone (there are a few others, but I think I can just take care of those rather easily, based on a different field).
I have done some VBA in Excel (haven't done much in the past year or so), but I can't think of what would be the best way to check for specific formatting in the cells. I am sure there is a way, and there may be an altogether better method than I am currently dealing with.
Here is what I've gotten started with so far:
Code:
Private Sub FilterSSN()
Dim wb As Workbook
Dim ws As Worksheet
Dim x As Long [green]'Long Integer Variable used for counting rows[/green]
Dim bolLoop As Boolean [green]'True if to continue Looping because there is still a record, or False if no record to check.[/green]
Set wb = ActiveWorkbook
Set ws = wb.Worksheets(ActiveWorksheet)
x = 2
bolLoop = True
Do While bolLoop = True
If ws.Cells(x, 1) = vbNullString Then bolLoop = True
Else
Select Case ws.Cells(x, 3).Formula
~just psuedo-code here...
Case Format1
Copy Row to Sheet1
Case Format2
Copy Row to Sheet2
Case Format3
Copy Row to Sheet3
Case Format4
Copy Row to Sheet4
Case Else
Copy Row to SheetUnknowns 'For manual review
End Select
End If
Loop
End Sub
Of course, the error handling and every detail has not been worked out yet, but I'm trying to get the idea down pat before I worry about the extras.
Any suggestions would be greatly appreciated. Thanks in advance.