【发布时间】:2015-03-26 20:34:26
【问题描述】:
我是一名新手 vba 编码器,迫切需要一些帮助。
使用下面另一篇文章中的代码,我已将其修改为初学者(可能是错误的方法),我需要
- 循环遍历工作表测试中的整个 A 列。
- 计算该区域中包含数据的单元格数。
- 使用该计数,我需要将文件复制到一个目录中,该目录多次将循环中的下一个数字附加到文件名中。
例如,如果我发现 210 个包含数据的单元格,我想将这个文件 C:\image\test.tif 复制 210 次到 C:\temp\imagecopy\test (1).tif,然后是 C:\temp\imagecopy\test (2).tif" 和 C:\temp\imagecopy\test (3).tif 等等。
但我真的不知道如何实现这一点。这是我目前所拥有的。
Sub CountTextPatterns()
Dim rngToCheck As Range
Dim cl As Range
Set rngToCheck = Range("A1:A10000") //Set up the range that contains the text data
Dim nothingHere As Integer
Set nothingHere = ""
//Loop through range, match cell contents to pattern, and increment count accordingly
For Each cl In rngToCheck
If nothingHere.Test(cl) Then
nothingHere = nothingHere+ 1
End If
Next
//For anything that isn't a letter or number, simply subtract from the and total row count
cntNumber = rngToCheck.Rows.Count - cntnothingHere
End Sub
//So at this point I believe I should have the total cells that are not blank. Now I need to execute a file copy action that many times using the logic mentioned at the top.
任何人都可以提供任何帮助,我们将不胜感激!
【问题讨论】: