|
Anthony's VBA Forum Where the knowledge is shared |
|
|
View previous topic :: View next topic |
Author |
Message |
hockey12
Joined: 04 Sep 2008 Posts: 1
|
Posted: Thu Sep 04, 2008 1:08 pm Post subject: Accounts Recievable Filter and Save each to new work book. |
|
|
I ama novice with excel and VB. Did take VB in college but that was a few years ago. I've been trying to figure out how to separate some information and save each into its own workbook so that i can send each file to its designated sales rep. I tried using this code that i found on here:
Set RngRawData = Worksheets ("Sheet1 or whatever your raw data sheet is called").Range("A1").CurrentRegion
Set RngOutput = Worksheets("Sheet that holds output headers").Range("A1:E1") ' ie just the column headers from columns A, B D, G and I
Set RngCriteria = Worksheets("Sheet that holds the filter criteria").Range("A1:C3") 'whatever your criteria for your sales rep is
RngRawData.AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=RngCriteria, _
CopyToRange:=RngOutput, _
Unique:=False
[/code:1]
You could then easily code it to copy this sheet to a new book
[code:1]
Dim strDate As String
Const strWbPath As String = "I:\Name of Folder that's going to hold the Field copies\" ' or whatever your new workbook path is
'set Dateformat
strDate = Format(Date, "yyyy.mm.dd")
ActiveWorkbook.SaveAs _
FileName:=strWbPath & strDate & " New Book Name.xls", _
FileFormat:=xlNormal, _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Windows("Original Workbook Name.xls").Activate
[/code:1]
to do what i needed but it doesn't quite work. what i am trying to do is keep the header of the page and then filter out the sales rep number and all the information tied to that number and put it in its own work book and save it with the file name + sales rep number. so here the original sheet looks like
Headers are A1:K8
A9 / B9 / C9 / D9 / E9 etc
cust # / cust name / total amt due / phone # / sales rep # etc ...
2345 / u of m / 300 / 555-1212 / 005
3345 / u of penn / 350 / 555-1313 / 006
4345 / usc / 600 / 555-1414 / 006
and the list goes on.. i have 005 -040 for sales reps number and numbers do repeat. so i need to filter the sales rep number and copy that data to a new workbook and save it as its own file. is there and easy way to do this? |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|