通过指定的纸张循环

时间:2015-10-14 08:58:43

标签: excel-vba vba excel

我正在尝试遍历工作簿中的指定工作表并分配标签等。我收到消息“运行时错误'9'下标超出范围。这是我正在使用的代码...

Sub Labels()

Dim intStartRow As Integer
Dim intRowCount As Integer
Dim intRow As Integer
Dim WshtNames As Variant
Dim intSheet As Variant

intStartRow = 32

WshtNames = Array("shtAngola", "shtBotswana", "shtMozambique", "shtNamibia", "shtSA", "shtZambia", "shtZimbabwe", "shtEritrea", "shtEthiopia", "shtKenya", "shtRwanda", "shtTanzania", "shtUganda", "shtAlgeria", "shtEgypt", "shtMorocco", "shtTunisia", "shtGhana", "shtIvoryCoast", "shtMauritius", "shtNigeria", "shtSenegal")

For Each intSheet In WshtNames

   With Worksheets(intSheet)

      For intRowCount = 7 To 21
           For intRow = 1 To 3
               .Cells(intStartRow, 1) = shtSelections.Cells(intRowCount, 1)

非常感谢你的帮助。

最佳, 亚当

1 个答案:

答案 0 :(得分:0)

或许你会将一行与标记标志相关联。所以你使用第二个自动变量循环。 intStowRow intRowCount instad。

.Cells(intRowCount,1)= shtSelections.Cells(intRowCount,1)

相关问题