¦U¦ì«e½ú¡G
¤p§Ì°µ¤F¤@ÓEXCEL¥¨¶°¡A¦b°õ¦æ®É·|®É¦n®ÉÃa¡C
½Ð±Ð¤£ª¾À³¸Ó¦p¦ó³B¸Ì- Sub COMBIN()
- '
-
-
- Cells.Select
-
- Cells.Replace What:=" ", Replacement:="", LookAt:=xlPart, SearchOrder:= _
- xlByRows, MatchCase:=False
-
- Range("c1").Select
- ActiveCell.FormulaR1C1 = "chkno"
-
- Call chkno
-
- Range("d1").Select
-
- End Sub
- Sub chkno()
- '
- '
- Dim myrow As Long
- Dim i As Integer
- myrow = Range("a1").End(xlDown).Row
- For i = 2 To myrow
-
- Selection.NumberFormatLocal = "@"
-
-
- 'If Not IsError(Cells(i, 1) <= 99999 And Cells(i, 2) <= 999) Then
- If Not IsError(Cells(i, 1).NumberFormatLocal = "0" And Cells(i, 4).NumberFormatLocal = "0") Then
- Cells(i, 3).Value = _
- String(6 - Len(Cells(i, 1)), "0") & Cells(i, 1) & String(4 - Len(Cells(i, 2)), "0") & Cells(i, 2)
-
- ElseIf Not IsError(Cells(i, 1).NumberFormatLocal = "@" And Cells(i, 4).NumberFormatLocal = "0") Then
- Cells(i, 3).Value = _
- Cells(i, 1) & String(4 - Len(Cells(i, 2)), "0") & Cells(i, 2)
-
- ElseIf Not IsError(Cells(i, 1).NumberFormatLocal = "0" And Cells(i, 2).NumberFormatLocal = "@") Then
- Cells(i, 3).Value = _
- String(6 - Len(Cells(i, 1)), "0") & Cells(i, 3) & String(4 - Len(Cells(i, 2)), "0") & Cells(i, 2)
- Else
-
- Cells(i, 3).Value = Cells(i, 1) & Cells(i, 2)
- End If
-
- Next i
-
- End Sub
½Æ»s¥N½X ¦pªþ¥ó
COMBIN.rar (9.88 KB)
|