標題:
貼入製造號碼後自動於G2產生填滿效果
[打印本頁]
作者:
霸氣走全身
時間:
2010-9-2 00:01
標題:
貼入製造號碼後自動於G2產生填滿效果
請問一下
貼入製造號碼後自動於G2產生填滿效果
10005874-1-6
於G2自動產生
10005874-1
10005874-2
10005874-3
10005874-4
10005874-5
10005874-6
是用函數還是巨集才可以呢
如附件
請幫忙~~~
謝謝
作者:
Hsieh
時間:
2010-9-2 08:48
Sub getmynumber()
Dim Ay(), A As Range, Ar As Variant, s&, i%
For Each A In Range([C2], [C65536].End(xlUp))
If Len(A) - Len(Replace(A, "-", "")) = 2 Then
Ar = Split(A, "-")
For i = Val(Ar(1)) To Val(Ar(2))
ReDim Preserve Ay(s)
Ay(s) = Ar(0) & "-" & i
s = s + 1
Next
Else
ReDim Preserve Ay(s)
Ay(s) = A
s = s + 1
End If
Next
[G2:G65536] = ""
[G2].Resize(s, 1) = Application.Transpose(Ay)
End Sub
複製代碼
作者:
霸氣走全身
時間:
2010-9-5 09:54
回復
2#
Hsieh
dear Hsieh
謝謝你喔~~
真的可以耶
^^
作者:
toomellowhaw
時間:
2010-9-10 22:09
權限不足,無法下載你的檔案,所以暫時假定你的製造號碼貼在[G1]格內,那麼只要在[G2]格內輸入下列公式,再拖曳複製至所需列數即可....笨方法,請指教..
=IF(--(ROWS($2:2)+MID($G$1,FIND("-",$G$1)+1,FIND("-",$G$1,FIND("-",$G$1)+1)-FIND("-",$G$1)-1)-1)<=--RIGHT($G$1,LEN($G$1)-FIND("-",$G$1,FIND("-",$G$1)+1)),LEFT($G$1,FIND("-",$G$1)-1)&"-"&(ROWS($2:2)+MID($G$1,FIND("-",$G$1)+1,FIND("-",$G$1,FIND("-",$G$1)+1)-FIND("-",$G$1)-1)-1),"")
作者:
霸氣走全身
時間:
2011-3-25 00:09
回復
2#
Hsieh
請問你
如果是
客戶 尺寸 製造號碼 BP數
AAA 110*550 1009564-1 2
BBB 333*545 01006505-1-2 4
可以轉換成如下,BP數 2 轉換成2比同樣號碼,但是後面會以A~B區分~~BP數 4 會 A~B~C~D 區分
AAA 110*550 1009564-1A
AAA 110*550 1009564-1B
BBB 333*545 01006505-1A
BBB 333*545 01006505-1B
BBB 333*545 01006505-1C
BBB 333*545 01006505-1D
BBB 333*545 01006505-2A
BBB 333*545 01006505-2B
BBB 333*545 01006505-2C
BBB 333*545 01006505-2D
這樣也可以嗎
再次麻煩妳了
謝謝
作者:
Hsieh
時間:
2011-3-25 11:21
回復
5#
霸氣走全身
Sub SSS()
Dim Ay(), A As Range, Ar As Variant, s&, i%
For Each A In Range([D2], [D65536].End(xlUp))
If Len(A) - Len(Replace(A, "-", "")) = 2 Then
Ar = Split(A, "-")
For i = Val(Ar(1)) To Val(Ar(2))
For j = 1 To A.Offset(, 1)
If A.Offset(, 1) > 1 Then temp = Chr(64 + j) Else temp = ""
ReDim Preserve Ay(s)
Ay(s) = Array(A.Offset(, -2).Value, A.Offset(, -1).Value, Ar(0) & "-" & i & temp)
s = s + 1
Next
Next
Else
For j = 1 To A.Offset(, 1)
If A.Offset(, 1) > 1 Then temp = Chr(64 + j) Else temp = ""
ReDim Preserve Ay(s)
Ay(s) = Array(A.Offset(, -2).Value, A.Offset(, -1).Value, A.Value & temp)
s = s + 1
Next
End If
Next
[K2:M65536] = ""
[K2].Resize(s, 3) = Application.Transpose(Application.Transpose(Ay))
End Sub
複製代碼
作者:
FAlonso
時間:
2011-3-26 13:58
樓主1樓
Sub abc()
Dim head(), body(), tail(), mycell As Range, i As Integer, j As Integer, k As Integer
For Each mycell In Range([c2], [c65536].End(xlUp))
ReDim Preserve head(i)
ReDim Preserve body(i)
ReDim Preserve tail(i)
head(i) = Split(mycell, "-")(0)
body(i) = Split(mycell, "-")(1)
tail(i) = Split(mycell, "-")(2)
i = i + 1
Next
Range("h2").Activate
For j = 0 To UBound(head)
For k = body(j) To tail(j)
ActiveCell.Value = head(j) & "-" & k
ActiveCell.Offset(1).Activate
Next
Next
End Sub
複製代碼
樓主5樓
Sub myprint()
Dim mycell As Range, head(), body(), tail(), BPnumber(), i As Integer
Dim j As Integer, bp As Integer, k As Integer, l As Integer
For Each mycell In Range([d2], [d65536].End(xlUp))
ReDim Preserve head(i)
ReDim Preserve body(i)
ReDim Preserve tail(i)
ReDim Preserve BPnumber(i)
head(i) = Split(mycell, "-")(0)
body(i) = Split(mycell, "-")(1)
If UBound(Split(mycell, "-")) = 2 Then
tail(i) = Split(mycell, "-")(2)
Else
tail(i) = ""
End If
BPnumber(i) = mycell.Offset(, 1).Value
i = i + 1
Next
Range("L2").Activate
For j = 0 To UBound(head)
If tail(j) = "" Then
If BPnumber(j) = 1 Then
ActiveCell = Cells(j + 2, 2).Value
ActiveCell.Offset(, 1) = Cells(j + 2, 2).Offset(, 1).Value
ActiveCell.Offset(, 2) = head(j) & "-" & body(j)
ActiveCell.Offset(1).Activate
Else
For bp = 1 To BPnumber(j)
ActiveCell = Cells(j + 2, 2).Value
ActiveCell.Offset(, 1) = Cells(j + 2, 2).Offset(, 1).Value
ActiveCell.Offset(, 2) = head(j) & "-" & body(j) & Chr(64 + bp)
ActiveCell.Offset(1).Activate
Next
End If
Else
If BPnumber(j) = 1 Then
For k = body(j) To tail(j)
ActiveCell = Cells(j + 2, 2).Value
ActiveCell.Offset(, 1) = Cells(j + 2, 2).Offset(, 1).Value
ActiveCell.Offset(, 2) = head(j) & "-" & k
ActiveCell.Offset(1).Activate
Next
Else
For k = body(j) To tail(j)
For bp = 1 To BPnumber(j)
ActiveCell = Cells(j + 2, 2).Value
ActiveCell.Offset(, 1) = Cells(j + 2, 2).Offset(, 1).Value
ActiveCell.Offset(, 2) = head(j) & "-" & k & Chr(64 + bp)
ActiveCell.Offset(1).Activate
Next
Next
End If
End If
Next
End Sub
複製代碼
土法大煉鋼,比較繁複和慢一點
另外5樓附檔D7一欄,最右手面有多餘空格,會影響結果,要小心處理
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)