|
- Sub Main()
- Dim rng As Range, colName$, arr(), i&
-
- Set rng = [A1:A300]
- arr = rng.Value
- colName = IncreaseColumnName(rng.Cells(1))
-
- For i = 1 To UBound(arr)
- arr(i, 1) = Format(Now(), "yyyymmdd") & colName & Format(i, "000")
- Next
-
- rng.Value = arr
- End Sub
- Function IncreaseColumnName(str)
- Dim strCol$, strDate$, nextColAddr$
-
- strCol = Mid(str, 9, 2)
- strDate = Left(str, 8)
-
- If Len(strCol) <> 2 Or strDate <> Format(Now(), "yyyymmdd") Then
- IncreaseColumnName = "ab"
- Else
- nextColAddr = Columns(strCol).Offset(, 1).Address(False, False)
- IncreaseColumnName = LCase(Left(nextColAddr, 2))
- End If
- End Function
复制代码 |
|