Hi to all experts,
I have a problem to be solved that is probably easy for an expert. I can make a simple macro – in most cases based on a recorded macro. For this is typical VBA programmers knowledge required.
Description of my problem:
I have a workbook (database) with the following contents:
First tab (worksheet) contains documentation and a list of organisations (with ‘shortname’ in col N rows 200 to 340 - last can vary by year). Col O contains a “0” = not yet processed and “1” = data has been processed.
Per organisation the data is saved in a worksheet (name equal to ‘shortname’).
Every year all organisations are sent a questionnaire (excel sheet). Answers have to be entered in col E rows 12 to 40. When xls files have been returned (over e period of about 4 weeks), the answers have to be copied to the specific worksheet in my database. All in same col and rows. All returned data is used for later analysis.
I know how to copy data in a macro, but my problem is in reading the files – and handling files not found. I like to make a macro for this problem because the whole exercise is performed twice per year.
I ‘designed’ the flow of statements in the macro as something like: (if you have a better idea then I am happy to accept that …!)
Find first (N200) and last shortname
Do until last shortname has been processed
If col O contains “1” then goto nextfile (this file has been processed in previous run)
Make filename with this shortname (filename = year_n_shortname; n can be 1 or 2)
Open filename (‘Answersheet’ - all files are in same directory)
If filename found Then
Enter “1” in col O ( database/sheet1 - next to shortname) – this to indicate
that this ‘shortname’ has returned an answer
Activate Databaseworksheet (shortname)
Copy col E 12 to 40 of answersheet(shortname) to col M rows 12 to 40 in
Databaseworksheet (shortname)
Close this Filename (Answersheet).
EndIf
Nextfile:
Col N row +1
Loop
As said before my problem is the VBA coding for handling files (open – recognising found/not found) – copying data to proper database worksheet.
Thanks for your help
Paul
I have a problem to be solved that is probably easy for an expert. I can make a simple macro – in most cases based on a recorded macro. For this is typical VBA programmers knowledge required.
Description of my problem:
I have a workbook (database) with the following contents:
First tab (worksheet) contains documentation and a list of organisations (with ‘shortname’ in col N rows 200 to 340 - last can vary by year). Col O contains a “0” = not yet processed and “1” = data has been processed.
Per organisation the data is saved in a worksheet (name equal to ‘shortname’).
Every year all organisations are sent a questionnaire (excel sheet). Answers have to be entered in col E rows 12 to 40. When xls files have been returned (over e period of about 4 weeks), the answers have to be copied to the specific worksheet in my database. All in same col and rows. All returned data is used for later analysis.
I know how to copy data in a macro, but my problem is in reading the files – and handling files not found. I like to make a macro for this problem because the whole exercise is performed twice per year.
I ‘designed’ the flow of statements in the macro as something like: (if you have a better idea then I am happy to accept that …!)
Find first (N200) and last shortname
Do until last shortname has been processed
If col O contains “1” then goto nextfile (this file has been processed in previous run)
Make filename with this shortname (filename = year_n_shortname; n can be 1 or 2)
Open filename (‘Answersheet’ - all files are in same directory)
If filename found Then
Enter “1” in col O ( database/sheet1 - next to shortname) – this to indicate
that this ‘shortname’ has returned an answer
Activate Databaseworksheet (shortname)
Copy col E 12 to 40 of answersheet(shortname) to col M rows 12 to 40 in
Databaseworksheet (shortname)
Close this Filename (Answersheet).
EndIf
Nextfile:
Col N row +1
Loop
As said before my problem is the VBA coding for handling files (open – recognising found/not found) – copying data to proper database worksheet.
Thanks for your help
Paul