[英]How to loop thru list of words and test these in RegEx in Excel VBA?
[英]How to loop thru an excel workbook using VBA
我正在尝试遍历excel工作簿中的每个工作表。 我的代码仅通过第一张纸运行,并且无法识别最后一行。 任何帮助将不胜感激。
Private Sub calculateValue()
For i = 2 To Rows.Count
If Cells(i, 4).Value < 10 Then
Cells(i, 6).Value = 20
End If
If Cells(i, 4).Value > 9 And Range("D2").Value < 40 Then
Cells(i, 6).Value = 70
End If
If Cells(i, 4).Value > 39 Then
Cells(i, 6).Value = 120
End If
If Cells(i, 4).Value = Empty Then Exit For
Next i
Cells(i, 6).Value = ""
End Sub
下面的第一个子项遍历每个工作表。 第二个是代码的占位符。
Sub forEachWs()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Call calculateValue(ws)
Next
End Sub
Sub calculateValue(ws As Worksheet)
'Worksheets(ws).Activate
'iterate over cells
'your code goes here
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.