Large project, first time calling subs and using error handling

Shakeable_Drip

Board Regular
Joined
May 30, 2023
Messages
52
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm working on my first large macro where I think I'll want to future proof it by splitting it up and I'll need to implement some hardy Error handling.
I'll ask specific questions in separate posts linking back to this one and update it with links out as it progresses. I appreciate everyone's time and interest!
I'll outline my goal below, but for this thread in general I'd like help in organizing: IE, should I use separate module's, should I contain it all in one place, for error handling can I make a sub for that, just call it on my IF ERROR's, what's the difference between subs, private subs, public subs, are there others?

general goal for project: 1 button macro to gather, convert, import, organize, and dissemble multiple large txt files of CNC machine code into reports that a user can print.
Why am I doing this?: because I don't have access to the software that makes reports currently and there are issues with current reports that justify this project.

Goal by tasks below:
A.1 create a folder called "temp" in same Dir as workbook <---done
A.2 copy files in the same Dir as workbook with the extension .BPX <--- done
A.3 paste files in same dir + \temp <--- done
A.4 change the extension from .BPX to .TXT <--- done
A.5 error handling <--- incomplete, maybe I should call a sub for error handling somehow?
A.5.1 if folder exists <--- done
A.5.2 if no .BPX exist <--- not done
A.5.3 msg box for errors <--- could be better
A.6 msg box "stage one complete" <--- Could be done better I think
B.1 import each .TXT file into separate columns on sheet "txt_data" <--- almost done, I think I was given the correct answer here
B.2 append FILE NAME to code <---- done but Id much rather prepend or overwrite line 2 than append, I'll ask in separate post
B.3 Error handling? I don't think its needed, if no .TXT or folder exist it would error handle before this point

C.1 count the number of columns on "txt_data" (DIM txt columns AS *something* long?) and "DO SOMETHING01" this one is hugely important and I want to be open to any way of doing it, but my goal is that any user can hit print(or save as PDF), and it prints a report per each column of "txt_data"... my thinking at the moment is to have a "template report sheet" and copy it X times and each sheet would look (or reference) the next column in "txt_data" I'll ask this in a separate post and link here soon. unfortunately the ROWS of data will be inconsistent, A19 could be a different portion of data from B19

D.1 utilize Vlookup or INDEX and loops (unless there is a better way) and search the columns on "txt_data" for key words and dissemble them on the the reports sheet

E.1 Hide "txt_data" and maybe "report_template" from user and printing

F.1 error handling for if the workbook already contains reports, option1 reset and run, option 2 stop

G.1 save workbook, save reports as PDF, and close

Z.1 Small chance I may need to convert this macro and workbook to "google sheets", but I'm resisting that possibility, conversion would be handled in a completely different thread.

attached is a sample CNC code that I'll figure out how to make reports for. cant attach for copy write, but essentially each line in the code is like the following: <_jobnote> TEST 999,REM@146 </_jobnote>
attached is "test2" my current workbook as of posting (once i get to my PC I'll attach and comment below)<--- I intend to rewrite/clean-up all macros once functionality is proven.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top