tanyamc
10-26-2021, 03:21 PM
Many thanks to p45cal (http://www.vbaexpress.com/forum/member.php?3494-p45cal) for the help with this project so far in this thread: http://www.vbaexpress.com/forum/showthread.php?69297-Total-filtered-rows-Range-of-object-Global-failed
Starting a new thread per the rules for the next piece.
I have a worklist that filters a raw data file and creates PDFs for each row in the worklist.
I need to customize the name for the PDFs. (They are currently being named based on the filter criteria cell, Funded Program, which is only part of the desired name.)
The names will come from the worklist file row containing the cell that is being used to filter the detail file.
The file name needs to be:
[Sales Order Number]_[Funded Program]_SD_[Fiscal Year]_[FISCAL PERIOD]
This code works for the first one, but I need to increment the row number in the 'set' lines to match the iLastRow_unique. I'm not sure how best to do that.
Many thanks!
For Each Cell In UniqueRng
ListObj.Range.AutoFilter Field:=4, Criteria1:=Cell
'create variables for file names
Dim SO As Range
Dim FY As Range
Dim FM As Range
'these need to increment with loop through the iLastRow_unique
Set SO = wbk_worklist.Sheets("SD_List").Range("B2")
Set FY = wbk_worklist.Sheets("SD_List").Range("C2")
Set FM = wbk_worklist.Sheets("SD_List").Range("D2")
Name = DirectoryLocation & "\" & SO.Value & "_" & Cell.Value & "_SD_" & FY.Value & "_" & FM.Value & ".pdf"
Starting a new thread per the rules for the next piece.
I have a worklist that filters a raw data file and creates PDFs for each row in the worklist.
I need to customize the name for the PDFs. (They are currently being named based on the filter criteria cell, Funded Program, which is only part of the desired name.)
The names will come from the worklist file row containing the cell that is being used to filter the detail file.
The file name needs to be:
[Sales Order Number]_[Funded Program]_SD_[Fiscal Year]_[FISCAL PERIOD]
This code works for the first one, but I need to increment the row number in the 'set' lines to match the iLastRow_unique. I'm not sure how best to do that.
Many thanks!
For Each Cell In UniqueRng
ListObj.Range.AutoFilter Field:=4, Criteria1:=Cell
'create variables for file names
Dim SO As Range
Dim FY As Range
Dim FM As Range
'these need to increment with loop through the iLastRow_unique
Set SO = wbk_worklist.Sheets("SD_List").Range("B2")
Set FY = wbk_worklist.Sheets("SD_List").Range("C2")
Set FM = wbk_worklist.Sheets("SD_List").Range("D2")
Name = DirectoryLocation & "\" & SO.Value & "_" & Cell.Value & "_SD_" & FY.Value & "_" & FM.Value & ".pdf"