Forum Discussion
lmg001115
May 21, 2025Copper Contributor
网赌被黑怎么办 有办法挽救吗?
(wx:RYG622)(QQ:157764444)(飞机@lmg567)先出款,后收费!
I have a macro that I've written to "reformat" some data in Excel (not font types and colors and such, but how the data is laid out in the spreadsheet). I found a macro that records how long it takes a macro to run, and that macro consistently runs for about 30 seconds.
The problem is that the reason I'm reformatting the data is to import into Access, and I don't want my users to have to have intimate knowledge of Access or Excel to reformat the data and import it into the Access database. Thus, I've created a form with a button that allows the user to select a file from a dialog box, and then the macro runs on that file.
Ad for some reason, when done this way, the macro takes upwards of 6 minutes.
I don't know if it would be helpful to post the code of the macro here, or if there's some generic advice that will help. I just can't imagine why this increase in run-time is happening.
1 Reply
Sort By
- NikolinoDEGold Contributor
Platform VBA Support Office Scripts Power Automate Notes Excel for Mac ❌ Limited ❌ ✅ VBA may work, but not consistently or at all on newer Macs (especially Apple Silicon) Excel on Mobile ❌ ❌ ✅ (via cloud) Can't run VBA or Office Scripts directly Excel Online (Web) ❌ ✅ ✅ Full support for Office Scripts and Power Automate Power BI ❌ N/A ✅ Uses Power Query (M language), not VBA Office Scripts N/A ✅ ✅ Replaces VBA for Excel Online automations function main(workbook: ExcelScript.Workbook) { const sheet = workbook.getActiveWorksheet(); // Example: Trim and clean values in range A2:D100 const range = sheet.getRange("A2:D100"); const values = range.getValues(); for (let i = 0; i < values.length; i++) { for (let j = 0; j < values[i].length; j++) { if (typeof values[i][j] === "string") { values[i][j] = (values[i][j] as string).trim(); } } } range.setValues(values); // Optional: Remove blank rows, sort, etc. }
You can add this via the Automate tab in Excel for the Web (not available on desktop yet for Mac).
…Use Power Automate + Office Scripts
You can:
- Create a button in Excel Online to trigger a script
- Or schedule/trigger it via Power Automate
Example:
- Upload a file
- Power Automate calls your Office Script
- Script reformats data
- Sends cleaned file to OneDrive, SharePoint, or Access via connector
...with some help from AI 🙂
My answers are voluntary and without guarantee!
Hope this will help you.