Dear Excellent Friends!
My existing macro comprises of different modules to perform specific task such as "LOOP_THROUGH_FOLDER_OPEN_FILE" - "PROCESS_FILE" - "SAVE_WORKBOOK"
To be specific:
1. Macro "LOOP_THROUGH_FOLDER_OPEN_FILE" to look for files with .XLS extension ( (say file1.xls, file2.xls....fileN.xls if there is as such) then CALL "PROCESS_FILE" to do the "process" and CALL SAVE_WORKBOOK to save the workbook.
2. "PROCESS_FILE" does the following process:
Example:
If file1.xls is opened, Range("M4") gets "VLOOKUP" value reference from other Workbook_WITH_LIST.XLS file (this contains list of data).
code:
Range("M1").Formula = "=VLOOKUP(M1,'C:\BACKUP \[Workbook_WITH_LIST.XLS]Sheet1'!$A:$N,2,FALSE)"
ActiveSheet.Cells(1, 1) = "Mr. John is" & Range("M4") & "yrs. old."
This procedure seems to work flawlessly provided that all files on that particular folder is listed on the Workbook_WITH_LIST.XLS.
All file on that folder is processed and I obtain the results i need.
However.....
My problem occurs when some files on that source folder is not on the list and "VLOOKUP" value referenced to Workbook_WITH_LIST.XLS returns #N/A. and the the macro hangs up.
I'm a novice on vb coding and I read that ERRORHANDLING will do provide the solution on my problem.
Please help me. What I need is that when that file is not on the list say: "VLOOKUP" value = #N/A, then:
a. macro will save that file to other directory
b. bypass "PROCESS_FILE and SAVE_WORKBOOK" process,
c. delete that file on that source folder
d. continue to process all files until all files on that folder is processed.
By that I can check those files that are not processed.
Btw, the source folder may contain more than 300 files for processing
Appreciate you help and patience on helping.
thanks in advance!
My existing macro comprises of different modules to perform specific task such as "LOOP_THROUGH_FOLDER_OPEN_FILE" - "PROCESS_FILE" - "SAVE_WORKBOOK"
To be specific:
1. Macro "LOOP_THROUGH_FOLDER_OPEN_FILE" to look for files with .XLS extension ( (say file1.xls, file2.xls....fileN.xls if there is as such) then CALL "PROCESS_FILE" to do the "process" and CALL SAVE_WORKBOOK to save the workbook.
2. "PROCESS_FILE" does the following process:
Example:
If file1.xls is opened, Range("M4") gets "VLOOKUP" value reference from other Workbook_WITH_LIST.XLS file (this contains list of data).
code:
Range("M1").Formula = "=VLOOKUP(M1,'C:\BACKUP \[Workbook_WITH_LIST.XLS]Sheet1'!$A:$N,2,FALSE)"
ActiveSheet.Cells(1, 1) = "Mr. John is" & Range("M4") & "yrs. old."
This procedure seems to work flawlessly provided that all files on that particular folder is listed on the Workbook_WITH_LIST.XLS.
All file on that folder is processed and I obtain the results i need.
However.....
My problem occurs when some files on that source folder is not on the list and "VLOOKUP" value referenced to Workbook_WITH_LIST.XLS returns #N/A. and the the macro hangs up.
I'm a novice on vb coding and I read that ERRORHANDLING will do provide the solution on my problem.
Please help me. What I need is that when that file is not on the list say: "VLOOKUP" value = #N/A, then:
a. macro will save that file to other directory
b. bypass "PROCESS_FILE and SAVE_WORKBOOK" process,
c. delete that file on that source folder
d. continue to process all files until all files on that folder is processed.
By that I can check those files that are not processed.
Btw, the source folder may contain more than 300 files for processing
Appreciate you help and patience on helping.
thanks in advance!
Last edited: