需要帮助排序宏。 [英] Need help with sort macro.

查看:59
本文介绍了需要帮助排序宏。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作表,我运行了一个宏列表,以及一个由工作表编辑的名为Orders.xls的工作表。它有4列,最多3000行。我记录了一个宏,按产品编号按D列对发票进行排序。此宏不会出错,但不会对任何数据进行排序。以下是我所尝试的宏的一个例子。

需要排序的数据:


产品详情产品产品

代码号码号码

----- ----- ----- -----

PHT PHOTOS 129 8

PRN PRINTER 1 139

PHN PHONE 3 23

排序结果


产品样品产品

代码号码号码

----- ----- ----- - ---

PHT PHOTOS 129 8

PHN PHONE 3 23

PRN PRINTER 1 139

=codeHolderclass =codeHolder>

展开 | 选择 | Wrap | 行号

解决方案

我对使用VBA排序并不熟悉。但是,我怀疑你的问题可能与你使用 Key1:= Range(D4)有关。不过,我不会声称知道应该是什么。如果其他人没有进去,我明天早上会看到这个,当我有可用的工具时。


我试过改变范围( D4)到我想象的一切,从要编辑的单元格范围到标题行的单元格,没有用。感谢您花时间协助解决此问题!



我尝试更改范围(D4) )到我能想到的一切,从要编辑的单元格范围到标题行的单元格,没有用。我感谢你花时间来协助这个!



通常,最简单的方法是获取正确的参数(或者至少得到一些关于如何处理它们的想法)是记录一个宏,并采取行动(在这种情况下,你自己。然后宏将包含你想要的代码。


我自己试过这个,我看到你的Key看起来很好(抱歉)。但是,只是为了看看它是否有任何区别,你能试试这个修改过的版本吗? (我现在假设你已经在ORDERS表中)

展开 | 选择 | Wrap | 行号


I have a worksheet that I run a list of macros from, and a sheet called Orders.xls that is edited by the worksheet. It has 4 columns, and a maximum of 3000 rows. I recorded a macro to sort the invoices by column D, by product number. This macro does not error, but does not sort any data. An example of what it sorts is below, also with the macro I am trying.

Data needing sorted:

PRODUCT PRODUCT PRODUCT PRODUCT
CODE NAME COUNT NUMBER
----- ----- ----- -----
PHT PHOTOS 129 8
PRN PRINTER 1 139
PHN PHONE 3 23

Result of sort:

PRODUCT PRODUCT PRODUCT PRODUCT
CODE NAME COUNT NUMBER
----- ----- ----- -----
PHT PHOTOS 129 8
PHN PHONE 3 23
PRN PRINTER 1 139

Expand|Select|Wrap|Line Numbers

解决方案

I''m not really familiar with using the Sort from VBA. However, I have a sneaking suspicion that your problem may be related to your use of Key1:=Range("D4"). I wouldn''t claim to know what it should be, though. If someone else doesn''t jump in, I''ll look into this tomorrow morning, when I have the tools available.


I''ve tried changing the Range("D4") to about everything I could imagine, from the range of the cells to be edited, to the cell which is the header row, with no avail. I appreciate you taking the time to assist with this!


I''ve tried changing the Range("D4") to about everything I could imagine, from the range of the cells to be edited, to the cell which is the header row, with no avail. I appreciate you taking the time to assist with this!

Usually the easiest way to get the parameters right (or at least get some ideas on what to do with them) is to record a macro, and do the action (in this case the sort) yourself. Then the macro will contain the code to do what you want.

Having just tried this myself, I see that your Key seems fine (sorry about that). However, just to see whether it makes any difference, could you try this modified version? (I''m assuming for the moment that you''re already in the ORDERS sheet)

Expand|Select|Wrap|Line Numbers


这篇关于需要帮助排序宏。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆