对不起,我对VBA很新,所以我一直在学习。我试图寻找一个答案,但我发现的一切似乎认为宏将在我想打开的文件中。Windows脚本打开Excel文件并运行宏
每月一次我得到一个包含一些数据的文件。到目前为止,我必须查看数据,然后在保存之前执行VLOOKUP以添加一些附加数据。
我现在已经写了一个VBA宏来添加我想要的附加信息,它的工作原理如下。然而,我想要做的是有一个Windows脚本,将打开我收到的文件,运行我写的宏,然后将文件保存为csv。
任何人都可以指向正确的方向吗?如果需要我的微距低于
Sub AddBandInfo()
Dim i As Long
For i = 2 To 50000
Dim band As String, result As Double
band = Range("B" & i).Value
If band = "A" Then result = 1144.02
If band = "B" Then result = 1334.7
If band = "C" Then result = 1525.36
If band = "D" Then result = 1716.04
If band = "E" Then result = 2097.38
If band = "F" Then result = 2478.72
If band = "G" Then result = 2860.08
If band = "H" Then result = 3432.08
If band = "" Then result = 0.01
Range("C" & i).Value = result
Next i
Dim r As Long
For r = Sheet1.UsedRange.Rows.Count To 1 Step -1
If Cells(r, "C") = "0.01" Then
Sheet1.Rows(r).EntireRow.Delete
End If
Next
End Sub
感谢
是否有一个特定的原因,您希望这是一个Windows脚本?您可以创建一个个人工作簿并使用VBA与FileDialog对象一起选择文件 –