vba代码改成vbs
我有一段写在Excel中的VBA代码,现在需要从Excel独立,写成vbs。
用vbs浏览文件名,打开文件的代码已经写好。现在只需要把vba代码中的on error resume next,goto等语句换掉。
原VBA代码(可用):
Private Sub CommandButton1_Click()
On Error Resume Next
Dim fill()
ReDim fill(1 To ActiveSheet.UsedRange.Columns.Count)
For i = ActiveSheet.UsedRange.Rows.Count To 1 Step -1
DoEvents
insert_count = 0
last_insert = 0
For y = 1 To ActiveSheet.UsedRange.Columns.Count
n = 0
If Len(Cells(i, y)) < 1 Then GoTo g_next1
If last_insert <> y Then i_count = insert_count
s_string = 0
s_string = WorksheetFunction.Find( "||| ", Cells(i, y), 1)
If s_string = 0 And Len(Cells(i, y).Value) > 0 Then fill(y) = True Else fill(y) = False
Do While True
s_string = 0
s_string = WorksheetFunction.Find( "||| ", Cells(i, y), 1)
If s_string = 0 Then GoTo g_next1
If last_insert = 0 Then
Rows(i + n + 1).Insert
insert_count = insert_count + 1
last_insert = y
Else
If last_insert = y Then
Rows(i + n + 1).Insert
insert_count = insert_count + 1
last_insert = y
Else