Excel Macro to find/replace in Sheets & VBA Modules - excel

I am looking to write a macro to have in my Personal Macro Workbook that will be able to be activated and run a series of Find/Replace's both on the worksheets of any Spreadsheet I have open and within the VBA of any macros inside that spreadsheet. The worksheets part of this is easy, but I cannot find a way to do it to the Visual Basic Editor, and trying to record the macro seems to not pick up anything done in VBA. I do not care if the code is clever enough to go through every VBA module or it needs to go "module1", "module2" and so on and run the find/replaces for each module seperately (because I guarantee that none of them are named otherwise); but so far, I have not been able to find anything that works and does an automatic find/replace in Excel VBA.
If it helps as an example, I am looking to change any reference in the VBA of "" to "/"
Thanks
I have found something online about using VBINDE to change constants; but I haven't been able to modify it to change text as above.

Related

How to save Lambda formula as Excel Add-In (or how to easily convert to VBA function?)

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.

Cannot run the macro Listbox4_Change. The macro May not be available in this workbook or all macros disabled

Can anyone please help me with excel issue. I have created a dynamic dashboard in excel using sumifs on data layer and index match functions on presentation layer. I have placed a simple List box form control with no VBA or macro.
My dashboard was working fine, without any issue, but on final step I was just trying to make the List box control float on the sheet with scrolling.
I found a vba code, I opened vba from developer mode, pasted code, but that deleted same.
Since then upon any selection of List box item, it is giving me error “ Cannot run the macro Listbox4_Change. The macro May not be available in this workbook or all macros disabled.”
I have tried pretty much every thing I found on google. Created a macro and deleted, copied one line code in all sheets of vba and deleted, enabled Macro security setting, but nothing really is working .
I am stuck badly.
It sounds like you've added a macro and then removed it, but haven't removed the macro assignment on the list box.
Right-click on the control and choose Assign Macro, delete the Macro name, and hit OK.

Generating a powerpoint presentation with VBA and Excel

I have a template presentation on powerpoint.
I would like to replace automatically generic placeholders with the value I input in an linked excel worksheet.
I started looking at VBA at the begining of the week, I am not really yet familiar with the syntax, but I am optimistic I will find a way to understand it.
I have put "[ ]" everywhere I want a value input:
the excel sheet present itself like this:
I would like to have some pointers (first, to know if it is indeed possible in powerpoint) to get me started in the right direction.
Does it need to be a PublicSub()?
Am I writing the macro on Powerpoint or in Excel?
Can I use a fonction similar to LookupV to get the values to replace the placeholders?
I would imagine something like :
(side question : can I use regex inside of VBA?)
for each "\[.\]" '(or characterString.startsWith("[")
lookup characterString in excel, return column 3
end each
Would this be possible?
Thank you in advance, I really appreciate the help.
Found an approximate solution, but simpler than code writing.
Open Excel,
fill the values, and copy them onto the powerpoint presentation : use the special paste option between the cell (or cells/cell range) you want.
Choose the "paste the link" option together with object worksheet Excel, select Ok.
Both files will be linked. You can change the values in Excel, and they will change also in powerpoint. The formating is done on excel.
In order to update all the values in the powerpoint after changing them on excel, powerpoint needs to be re-run, and at the restart of the application, accept the updating box prompt.
I find this simpler than the other solutions.

Excel: quick access to an external macro from any spreadsheet

I have a bunch of csv files that I create everyday and that I want to format nicely with colors and stuff.
So I wrote a macro that do all I want.
Now I'm looking for the most practical way to call that macro from Excel.
It looks like macros are stored in the spreadsheet and can't be "global" or "external".
So when I open a csv, I need to create a new macro, paste my vb code, and run it.
It would be great if I could add a button to Excel toolbar, or at least open a menu that will let me select the macro and run it.
It looks like one answer could be to create an excel add-in, but I'm not sure this is the right way to go.
Thanks a lot for your help
This will work with a so-called "Personal Macro Workbook". In Excel 2010, it will be called Personal.xlsb and reside somewhere in your users directory.
See http://office.microsoft.com/en-001/excel-help/copy-your-macros-to-a-personal-macro-workbook-HA102174076.aspx for details. This also applies with small variations to other versions of Excel.

Excel VBA macro not found by worksheet, #NAME

I'm trying to get a simple VBA function to run in an excel (.xlsm) worksheet.
I created this function:
Function abc()
abc = 2
End Function
in Module2, and it worked.
But after I copied the spreadsheet to another system, it now just shows "#name" as if it can't find it. The function shows up on the available list of functions however.
This makes me think there is some kind of setting I need to enable, but I've enabled whatever I was prompted for. Any ideas?
I should've known it was in the trust center:
http://office.microsoft.com/en-us/excel-help/change-macro-security-settings-in-excel-HP010096919.aspx
Basically, hit the ball and poke around until you find "trust" and "enable macros" and select the least secure options.
And then close and re-open the spreadsheet.
I think we may need more information. What version of Excel are you using? Is it different from the destination system version?
You'll want to make sure that Module2 was in the Workbook you copied into the other system. Excel 2007 stores macros on a personal workbook by default sometimes so you'll need to check the the code is actually inside of the .xlsm file.
If you're still stuck and need a quick fix just copy the code text into the new system's Excel workbook directly without making a .xlsm file (create new module in the other system then paste).
If you would like to learn how to put together add-ins you can get started here or here.

Resources