|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Dim lngRowId As Long
- Private Sub CommandButton1_Click()
- If TB3.Value = "" Then
- MsgBox "Please Enter [Letter]"
- Else
- MySet TB3.Value, TB4.Value
- MyInic
- End If
- End Sub
- Private Sub UserForm_Initialize()
- MyInic
- End Sub
- Private Function MyInic()
- Dim shSource As Worksheet, arrSource As Variant
- Dim lngRow_Start As Long, lngRow_End As Long
- Dim lngRow As Long, strTemp As String
- Dim strID As String, lngCount As Long
- Dim strResult(1 To 1, 1 To 5) As Variant
-
- Set shSource = Sheets("Sheet1")
- arrSource = shSource.UsedRange
- lngRow_Start = shSource.Range("C" & Rows.Count).End(xlUp).Row
- If lngRow_Start > 1 Then lngRow_Start = lngRow_Start + 1
- lngRow_End = shSource.Range("A" & Rows.Count).End(xlUp).Row
-
- For lngRow = lngRow_Start To lngRow_End
- strTemp = arrSource(lngRow, 1)
- If InStr(strTemp, ".") > 0 Then
- strTemp = Split(strTemp, ".")(0)
- If strID = "" Then
- lngRowId = lngRow
- strID = strTemp
- lngCount = lngCount + 1
- Else
- If strTemp = strID Then
- lngCount = lngCount + 1
- Else
- Exit For
- End If
- End If
- End If
- Next
-
- TB1.Value = ""
- TB2.Value = ""
- TB3.Value = ""
- TB4.Value = ""
- If strID <> "" Then
- TB1.Value = strID
- TB2.Value = lngCount
- TB3.Value = ""
- TB4.Value = lngCount
- End If
- End Function
- Private Function MySet(strChar As String, lngMax As Long)
- Dim lngRow As Long
- For lngRow = 1 To lngMax
- Sheet1.Range("C" & lngRowId + lngRow - 1).Value = strChar & lngRow
- Next
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|