# Automation RunExcelMacro Fails to sort the Rows

**URL:** <https://www.dynamicsuser.net/t/automation-runexcelmacro-fails-to-sort-the-rows/10423>\
**Category:** Developers Forum\
**Created:** [November 18, 2005, 9:38am UTC](https://www.dynamicsuser.net/t/automation-runexcelmacro-fails-to-sort-the-rows/10423 "2005-11-18T09:38:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RVBuson](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@RVBuson](https://www.dynamicsuser.net/u/RVBuson)\
**Post date:** [November 18, 2005, 9:38am UTC](https://www.dynamicsuser.net/t/automation-runexcelmacro-fails-to-sort-the-rows/10423/1 "2005-11-18T09:38:24Z")

</div>

I have a Spreadsheet with a macro that sorts the records, makes the Header Bold, etc. Automation does run the macro (I see that the header is bold) however it does not sort the records. If I manually run the macro after the export is completed the records are sorted. The command to run the macro is in the OnPostReport trigger before the Save Command. What can I do to solve the problem?

---

<div class="post-metadata">

**Author:** ![CMDunbar](https://avatars.discourse-cdn.com/v4/letter/c/e99b99/32.png) [@CMDunbar](https://www.dynamicsuser.net/u/CMDunbar)\
**Post date:** [November 18, 2005, 4:30pm UTC](https://www.dynamicsuser.net/t/automation-runexcelmacro-fails-to-sort-the-rows/10423/2 "2005-11-18T16:30:53Z")

</div>

Is this two separate macros or just one?

---

<div class="post-metadata">

**Author:** ![RVBuson](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@RVBuson](https://www.dynamicsuser.net/u/RVBuson)\
**Post date:** [November 19, 2005, 3:06am UTC](https://www.dynamicsuser.net/t/automation-runexcelmacro-fails-to-sort-the-rows/10423/3 "2005-11-19T03:06:24Z")

</div>

> **quote:**
> 
> | Is this two separate macros or just one? Just one I have found the real problem, namely the macro did not run. now that I invoke it correctly as follows: MyMacro :=‘SortByLoc’; xlApp.run(MyMacro); All is well. Thank you.  
> _Originally posted by CMDunbar - 2005 Nov 18 : 16:30:53_  
> |
> | --- |
