在Excel 2013中更改记录的VBA排序中的工作表

时间:2023-01-13 20:23:02

I recorded a simple sort macro in Excel 2013 but it put the worksheet name in the macro: ActiveWorkbook.Worksheets("JUL15").Sort.SortFields.Clear. I use the macro to sort a dozen different worksheets in different workbooks and they all have the same layout. How do I make the macro work on any spreadsheet that I choose?

我在Excel 2013中记录了一个简单的排序宏,但它将工作表名称放在宏中:ActiveWorkbook.Worksheets(“JUL15”)。Sort.SortFields.Clear。我使用宏来对不同工作簿中的十几个不同的工作表进行排序,它们都具有相同的布局。如何在我选择的任何电子表格上使宏工作?

Also, Excel, options, advanced, general: specify startup up pgm doesn't work. Path is valid and binary .xlsb is valid but it won't open at startup.

另外,Excel,选项,高级,通用:指定启动时pgm不起作用。路径有效且二进制.xlsb有效但在启动时不会打开。

I am not a programmer, at least on PC's.

我不是程序员,至少在PC上。

3 个解决方案

#1


0  

You can use ActiveSheet instead of ActiveWorkbook.Worksheets("JUL15")

您可以使用ActiveSheet而不是ActiveWorkbook.Worksheets(“JUL15”)

It will work on the sheet that is open.

它将在打开的工作表上工作。

#2


0  

Use Activesheet as suggested in your macro for working on the currently active sheet.

使用宏中建议的活动表来处理当前活动的工作表。

However, I think the other part of your question relates to using Personal.xlsb which starts up when Excel starts and will allow your macro to be available regardless of what spreadsheets you have open.

但是,我认为你问题的另一部分与使用Personal.xlsb有关,它在Excel启动时启动,无论你打开什么样的电子表格,都可以使用你的宏。

This should help get you going in that direction...https://support.office.com/en-ca/article/Copy-your-macros-to-a-Personal-Macro-Workbook-aa439b90-f836-4381-97f0-6e4c3f5ee566

这应该有助于您朝着这个方向前进... https://support.office.com/en-ca/article/Copy-your-macros-to-a-Personal-Macro-Workbook-aa439b90-f836-4381- 97f0-6e4c3f5ee566

EDIT: In case the file was disabled, you can try this: http://www.mrexcel.com/forum/excel-questions/506647-files-xlstart-not-opening-automatically.html

编辑:如果文件被禁用,你可以试试这个:http://www.mrexcel.com/forum/excel-questions/506647-files-xlstart-not-opening-automatically.html

(Go into the Add-ins and make sure the Personal.xlsb file is not on the Disabled list.)

(进入加载项并确保Personal.xlsb文件不在“禁用”列表中。)

#3


0  

This is the solution for converting macros in personal.xls in Excel 2010 and before to Excel 2013. Excel 2013 flags the personal.xls as an error and disables it. You can copy macros to a new personal.xlsb for 2013 but you need to go to 'Add-ins' and manage disabled items to enable the new personal.xlsb.

这是在Excel 2010及之前将Excel中的个人.xls中的宏转换为Excel 2013的解决方案.Excel 2013将personal.xls标记为错误并禁用它。您可以将宏复制到2013年的新Personal.xlsb,但您需要转到“加载项”并管理禁用的项目以启用新的personal.xlsb。

#1


0  

You can use ActiveSheet instead of ActiveWorkbook.Worksheets("JUL15")

您可以使用ActiveSheet而不是ActiveWorkbook.Worksheets(“JUL15”)

It will work on the sheet that is open.

它将在打开的工作表上工作。

#2


0  

Use Activesheet as suggested in your macro for working on the currently active sheet.

使用宏中建议的活动表来处理当前活动的工作表。

However, I think the other part of your question relates to using Personal.xlsb which starts up when Excel starts and will allow your macro to be available regardless of what spreadsheets you have open.

但是,我认为你问题的另一部分与使用Personal.xlsb有关,它在Excel启动时启动,无论你打开什么样的电子表格,都可以使用你的宏。

This should help get you going in that direction...https://support.office.com/en-ca/article/Copy-your-macros-to-a-Personal-Macro-Workbook-aa439b90-f836-4381-97f0-6e4c3f5ee566

这应该有助于您朝着这个方向前进... https://support.office.com/en-ca/article/Copy-your-macros-to-a-Personal-Macro-Workbook-aa439b90-f836-4381- 97f0-6e4c3f5ee566

EDIT: In case the file was disabled, you can try this: http://www.mrexcel.com/forum/excel-questions/506647-files-xlstart-not-opening-automatically.html

编辑:如果文件被禁用,你可以试试这个:http://www.mrexcel.com/forum/excel-questions/506647-files-xlstart-not-opening-automatically.html

(Go into the Add-ins and make sure the Personal.xlsb file is not on the Disabled list.)

(进入加载项并确保Personal.xlsb文件不在“禁用”列表中。)

#3


0  

This is the solution for converting macros in personal.xls in Excel 2010 and before to Excel 2013. Excel 2013 flags the personal.xls as an error and disables it. You can copy macros to a new personal.xlsb for 2013 but you need to go to 'Add-ins' and manage disabled items to enable the new personal.xlsb.

这是在Excel 2010及之前将Excel中的个人.xls中的宏转换为Excel 2013的解决方案.Excel 2013将personal.xls标记为错误并禁用它。您可以将宏复制到2013年的新Personal.xlsb,但您需要转到“加载项”并管理禁用的项目以启用新的personal.xlsb。