对于每个细胞,“循环中的细胞的顺序” [英] order of cells in loop "for each cell"

查看:188
本文介绍了对于每个细胞,“循环中的细胞的顺序”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有办法改变它?

我想知道是否有规则知道这个循环是否会完成?

假设我在多个工作簿上的多个工作表上有多个范围。

解决方案

是的,循环总是运行规则。你可以做一些实验,但我会给你一些信息(据我所知)。



工作簿:订单是从第一个打开/创建到上次打开/创建的。



工作表/表:订单,如果从左到右,您可以在应用程序中看到它们。



单元格在范围内):首先从左到右排列,接下来移至下一行(当我们用英文阅读和写入时)。



另外三个例子:



在Excel表格中的注释:根据注释所在单元格的地址,按顺序循环与单元格(见上文)一起出现。



Word文档中的注释:从文档的开头,按照外观的顺序。



MS Word中的书签按书签名称按字母顺序。






2013年8月8日编辑



Word文档中的书签顺序。实际上有两个订单:



1。此循环:

  Dim BM As Bookmark 
对于每个BM在ActiveDocument.Content.Bookmarks
下一个

将以文档内容(范围)



2。当此循环:

  Dim BM As Bookmark 
对于每个BM ActiveDocument.Bookmarks
下一个

将根据书签名称按字母顺序进行迭代。 >




使用对于...下一个循环可以使用步骤减去参数。



进行实验非常容易,我可以承认,很多时候知道循环迭代顺序。


I'm wondering if there is a rule to know in wich order the loop will be done ?

Is there a way to change it ?

Let's say I have multiple ranges on multiple sheets on multiple workbooks.

解决方案

Yes, there are always rules for loops to run. You could make some experiments but I'll give you some information (as far as I remember).

Workbooks: the order is from the first opened/created to last opened/created.

Worksheets/Sheets: the order if from left to right as you could see them in application.

Cells (in ranges): it goes first in row from left to right, next move to next row (as we read and write in English).

Three other examples:

Comments in Excel sheet: based on address of cell where the comment is located, in the order the loop goes with cells (see above).

Comments in Word document: from the beginning of the document, in the order of appearance.

Bookmarks in MS Word: alphabetically by bookmark's name.


Edit on 8th August 2013

I've just found something interesting regarding order of bookmarks in Word document. In fact there are two orders:

1. This loop:

    Dim BM As Bookmark
    For Each BM In ActiveDocument.Content.Bookmarks
    Next

will iterate in order of appearance of bookmarks in Document Content (Range)

2. While this Loop:

    Dim BM As Bookmark
    For Each BM In ActiveDocument.Bookmarks
    Next

will iterate in alphabetical order based on bookmark names.


When using For...Next loop you can reverse the order using Step minus parameter.

It's quite easy to make experiments and I could admit- quite often it's important to know the loop iteration order.

这篇关于对于每个细胞,“循环中的细胞的顺序”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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