我想用字母形式重命名目录中的所有文件。例如,我有一个名为 Temp 的文件夹,目录中的某些文件如下所示:
Dim i As Integer
Dim j As Integer
Private Sub ComboBox1_Change()
With UserForm3.ListBox1
.MultiSelect = fmMultiSelectSingle
.ListIndex = -1
.MultiSelect = fmMultiSelectMulti
For i = 0 To .ListCount - 1
For j = 0 To .ColumnCount - 1
If UserForm3.ComboBox1.Text = .Column(j, i) Then
.ListIndex = i
.Selected(i) = True
End If
Next j
Next i
End With
End Sub
Private Sub ComboBox2_Change()
With UserForm3.ListBox1
.MultiSelect = fmMultiSelectSingle
.ListIndex = -1
.MultiSelect = fmMultiSelectMulti
For i = 0 To .ListCount - 1
For j = 0 To .ColumnCount - 2
If UserForm3.ComboBox1.Text = .Column(j, i) Then
.ListIndex = i
.Selected(i) = True
End If
Next j
Next i
End With
End Sub
Private Sub ComboBox3_Change()
With UserForm3.ListBox1
.MultiSelect = fmMultiSelectSingle
.ListIndex = -1
.MultiSelect = fmMultiSelectMulti
For i = 0 To .ListCount - 1
For j = 0 To .ColumnCount - 3
If UserForm3.ComboBox1.Text = .Column(j, i) Then
.ListIndex = i
.Selected(i) = True
End If
Next j
Next i
End With
End Sub
我的目标是使目录中的所有文件看起来像这样
Temp/
1_1_1.jpg
1_1_2.jpg
1_1_3.jpg
...
但是当我运行代码时,它仅重命名一个文件,而对另一个文件没有更改。像这样:
Temp/
A-1.jpg
B-1.jpg
C-1.jpg
...
我很累,无法通过更改循环的变化找到解决方案,但结果却相同。这是我的最后一个代码
Temp/
A-1.jpg
1_1_2.jpg
1_1_3.jpg
...
我的代码有什么问题?请帮我。谢谢