我有疑问如何改进我的宏以通过 A 列,当它找到空白单元格时,它会在那里输入月份名称?我在下面尝试了类似的东西,但它只能用于Range("A1").value
而不是Cells(Rows.Count, "A").End(xlUp).Row
Sub actual_month()
'fill month col
Dim arrMonths() As String
ReDim arrMonths(1 To 12)
Application.DisplayAlerts = False
arrMonths(1) = "JAN"
arrMonths(2) = "FEB"
arrMonths(3) = "MAR"
arrMonths(4) = "APR"
arrMonths(5) = "MAY"
arrMonths(6) = "JUNE"
arrMonths(7) = "JULY"
arrMonths(8) = "AUG"
arrMonths(9) = "SEP"
arrMonths(10) = "OCT"
arrMonths(11) = "NOV"
arrMonths(12) = "DEC"
Workbooks("UAC_report_p.xlsb").Activate
Sheets("SLA Calculation").Select
For Each Cell In ActiveSheet.UsedRange.Cells
'do some stuff
Next
For i = 1 To 12
Cells(Rows.Count, "A").End(xlUp).Row = Month(Date)
If Cells(Rows.Count, "A").End(xlUp).Row.Value = Month(Date) Then _
Cells(Rows.Count, "A").End(xlUp).Row.Value = arrMonths(Cells(Rows.Count, "A").End(xlUp).Row.Value)
Next i
Application.DisplayAlerts = True
End Sub