|
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim i As Integer
- Dim rng As Range
- Dim x As String, y As String
- ' Debug.Print Target.Offset(5, -1)
- If Target.Address = "$H$1" Then
- Select Case Target.Value
- Case "[出库单]"
- x = "出库记录"
- y = "HC"
- Case "[入库单]"
- x = "入库录"
- y = "HR"
- Case Else
- '…………
- End Select
-
- Set rng = Sheets(x).Range("B65536").End(xlUp)
- If rng.Address = "$B$1" Then
- i = 1
- Else
- If Mid(rng.Value, 3, 6) = Format(Target.Offset(5, -1), "YYYYMM") Then
- i = Right(rng.Value, 3) + 1
- Else
- i = 1
- End If
- End If
-
- Target.Offset(2, 0) = y & Format(Target.Offset(5, -1), "YYYYMM") & Format(i, "000")
- End If
- End Sub
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|