I have a xls with some data, which i need to correct. For example: fix common typos, replace '4 parts' with 'four parts' etc.
Replacement rules are big key=>value arrays. So i just loop through them and do replacements.
I'd like to store those rules in single .yml files and load them in arrays as soon as my macro starts. I think it's easiest way to maintain them, because they are updated frequently. Unfortunately, vba seems to not have yaml parser.
Is there another way to keep my configuration beyond the macro?
Your Macro can be housed in another spreadsheet that is called to run on your target spreadsheet. So storing your rules in the Macros spreadsheet is possible. Editing the rules may not be as easy later, I kinda loath doing multi-line typing in Excel, but if you need a quick accessible data store it works.
Edit: And in reading your question again I see that you want to store this separate of the Macro. You could try json:
Is There a JSON Parser for VB6 / VBA?
Related
I made some very complex Lambda formulas which I use frequently to validate UPC Check digits, and convert UPCs from UPC-E to UPC-A format
I tried to set them up as named ranges, then save the workbook as an Add-In, and followed all the steps I could find to add that add-in into my Excel, however it doesn't look like it keeps the named ranges at all (which is where Lambda formulas are stored)
Is there any way to get around this and still save these Lambda formulas as an Add-in?
I really don't want to have to re-create the entire complex formula in a module, but it seems I may have to do that in order to have the formulas available in every workbook I open
Alternatively, if there's any way within a VBA function for me to use my existing Lambda formula, I would love that, but I'm not sure if that is possible as I know that VBA is a quite different language than Excel's formulas.
I considered making a macro which instead would just add those named ranges to my workbook, but hoping for an easier solution.
Please let me know if you have any tips for this!
What about maintaining a Template,that’s what I do, means they are there in your new books and a quick way to access them for manual copying across to existing workbooks.
2nd idea is use autocorrect to store them with a shortcut word. Autocorrect is application level and there is VBA you can find to copy your AC shortcuts to a backup workbook and reimport them if your PC crashes.
Does anyone have a function written or know how to translate an entire Excel sheet? Want to avoid doing this cell-by-cell, as I'm working with a lot of data. Also can't use third-party services as I'm handling sensitive information. I'm very much a newbie to Excel, so I probably won't be able to do anything complicated on my own.
I want to make a dynamic excel sheet that updates whenever a file is being created into a folder, think of letters. So the sheet needs to extract the name of the letter, the date&time when it is made, the author and so on, into a table in excel. Does anyone knows how to get that filedata?
I already know how to put data in a certain cell using VBA but the thing i get stuck in is how to get that data from a certain folder.
As Ron said, there is no event in VBA to handle that. However, if you want to stick to VBA only, you have basically two options:
You can update your cell whenever the workbook is opened using the Workbook.Open event (https://learn.microsoft.com/en-us/office/vba/api/excel.workbook.open). This is not really dynamic but might be sufficient (depending on your needs).
Other option would be to call a function periodically to check if the folder content has changed (https://learn.microsoft.com/en-us/office/vba/api/excel.application.ontime)... Not very performant, but would work for sure.
For the file data just follow Ron's suggestion.
Hope that helps, MJ.
I have an Excel sheet which is used for bug-tracking. Each client has their own .xlsx and each application for that client has its own sheet within the .xlsx. So multiple Excel files with multiple sheets, all in the same format.
All sheets have the same headings and some columns have data validation and conditional formatting. Occasionally, however, the layout/headings or values allowed in data-validated cells, etc. must change and I have to go through each sheet and manually make the changes.
Is it possible to have a master sheet from which other sheets will inherit headings and heading styles with all cells under particular headings having data validation and conditional formatting?
(Before this is suggested, I used to simply put everything in one sheet and use filters to show a particular client/application, but this became impractical when sharing and versioning the sheets with multiple people)
The term you are looking for is a template. You create the template and give that to your 'clients' to track bugs. If you make an update to the template and give it to the client, they can just copy/paste data into the new form.
In my opinion, you're going about this the wrong way. Excel is a spreadsheet programme, while it CAN be used as a 'list' of sorts, it is a poor choice for bug tracking. If you're stuck on Office applications, use an Access database or something that can actually give you a 'front end display' separate from the 'back end data'. There are many free bug tracking software programmes on the internet. Set one of them up and just have your clients log a bug there.
Using a template and then getting the clients to copy+paste the old data is one way, but its not exactly the safest method.
If you did want to distribute a new template to your users it would be a good idea to add some import functionality. So VBA handles copying the old data across.
If you (personally) could do the changes to the template manually, then you might also be able to create a workbook+macros to "patch" the source (or a copy of the source) data in-place.
With either approach you'd probably need to add something to the source workbook to keep track of what version they have and make sure they they import from and to the correct version to prevent unhappiness in the future.
Could you show an example of a change? before and after etc
Using Excel/Word 2007 I'm trying to copy multiple selections from Excel to Word. When I paste it into Word it's as if it ignored the break in the ranges and just pastes a range that includes everything I was trying to leave out.
For instance if I intend to copy/paste "A2:D4, A6:D7, A10:D11" what is actually pasted in word is "A2:D11", so it's ignoring the breaks in the selections. I can't seem to find any documentation on this issue anywhere. If someone knows anything I'd really appreciated it. I know I'm selecting the ranges properly because if I copy and paste the multiple ranges within Excel it works like it should.
The actual issue is that I have these actions automated in a macro and I'd really prefer not to loop through the individual ranges because they're stored in a dictionary and it would be just a real hassle. Despite that, it seems weird that I can't even accomplish the task manually.
I've done quite a bit of digging and can't seem to come up with anything. I thought about using the Office clipboard but you can't paste tables as an RTF. It doesn't seem like there are any options when pasting with the office clipboard.
AFAIK it doesn't seem possible and I've tried to exhaust all my normal avenues of knowledge before posting here. If anyone has ever just experienced this it would be comforting to know I'm not alone.
I don't know how to prevent that from happening, but you could potentially work around it by pasting your non-continuous selection into a continuous region in a new, temporary sheet/workbook, then copying the continuous region from the temp sheet/workbook into word.
a bit of a hassle, yes, but it should get the job done.