|
本帖最后由 JOHNJIANG-001 于 2022-8-14 11:35 编辑
自动分行太慢,1万行数据运行代码需要约3-5分钟,急需使用,求助大神,请大神协助优化代码,敬请大神指导,谢谢!
Sheet12.Select
Dim x&, i&, arr, j%
x = Sheet12.Range("C65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("C" & i).Value, "/")
For j = 0 To UBound(arr)
m = m + 1
Sheet13.Range("C" & m + 3) = arr(j)
Sheet13.Range("D" & m + 3) = Range("D" & i).Value
Sheet13.Range("E" & m + 3) = Range("E" & i).Value
Sheet13.Range("F" & m + 3) = Range("F" & i).Value
Next j
Next i
x = Sheet12.Range("I65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("I" & i).Value, "/")
For j = 0 To UBound(arr)
n = n + 1
Sheet13.Range("I" & n + 3) = arr(j)
Sheet13.Range("J" & n + 3) = Range("J" & i).Value
Sheet13.Range("K" & n + 3) = Range("K" & i).Value
Sheet13.Range("L" & n + 3) = Range("L" & i).Value
Next j
Next i
x = Sheet12.Range("O65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("O" & i).Value, "/")
For j = 0 To UBound(arr)
O = O + 1
Sheet13.Range("O" & O + 3) = arr(j)
Sheet13.Range("P" & O + 3) = Range("P" & i).Value
Sheet13.Range("Q" & O + 3) = Range("Q" & i).Value
Sheet13.Range("R" & O + 3) = Range("R" & i).Value
Next j
Next i
x = Sheet12.Range("U65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("U" & i).Value, "/")
For j = 0 To UBound(arr)
P = P + 1
Sheet13.Range("U" & P + 3) = arr(j)
Sheet13.Range("V" & P + 3) = Range("V" & i).Value
Sheet13.Range("W" & P + 3) = Range("W" & i).Value
Sheet13.Range("X" & P + 3) = Range("X" & i).Value
Next j
Next i
x = Sheet12.Range("AA65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("AA" & i).Value, "/")
For j = 0 To UBound(arr)
Q = Q + 1
Sheet13.Range("AA" & Q + 3) = arr(j)
Sheet13.Range("AB" & Q + 3) = Range("AB" & i).Value
Sheet13.Range("AC" & Q + 3) = Range("AC" & i).Value
Sheet13.Range("AD" & Q + 3) = Range("AD" & i).Value
Next j
Next i
x = Sheet12.Range("AG65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("AG" & i).Value, "/")
For j = 0 To UBound(arr)
R = R + 1
Sheet13.Range("AG" & R + 3) = arr(j)
Sheet13.Range("AH" & R + 3) = Range("AH" & i).Value
Sheet13.Range("AI" & R + 3) = Range("AI" & i).Value
Sheet13.Range("AJ" & R + 3) = Range("AJ" & i).Value
Next j
Next i
x = Sheet12.Range("AM65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("AM" & i).Value, "/")
For j = 0 To UBound(arr)
S = S + 1
Sheet13.Range("AM" & S + 3) = arr(j)
Sheet13.Range("AN" & S + 3) = Range("AN" & i).Value
Sheet13.Range("AO" & S + 3) = Range("AO" & i).Value
Sheet13.Range("AP" & S + 3) = Range("AP" & i).Value
Next j
Next i
x = Sheet12.Range("AS65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("AS" & i).Value, "/")
For j = 0 To UBound(arr)
T = T + 1
Sheet13.Range("AS" & T + 3) = arr(j)
Sheet13.Range("AT" & T + 3) = Range("AT" & i).Value
Sheet13.Range("AU" & T + 3) = Range("AU" & i).Value
Sheet13.Range("AV" & T + 3) = Range("AV" & i).Value
Next j
Next i
x = Sheet12.Range("AY65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("AY" & i).Value, "/")
For j = 0 To UBound(arr)
U = U + 1
Sheet13.Range("AY" & U + 3) = arr(j)
Sheet13.Range("AZ" & U + 3) = Range("AZ" & i).Value
Sheet13.Range("BA" & U + 3) = Range("BA" & i).Value
Sheet13.Range("BB" & U + 3) = Range("BB" & i).Value
Next j
Next i
x = Sheet12.Range("BE65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("BE" & i).Value, "/")
For j = 0 To UBound(arr)
V = V + 1
Sheet13.Range("BE" & V + 3) = arr(j)
Sheet13.Range("BF" & V + 3) = Range("BF" & i).Value
Sheet13.Range("BG" & V + 3) = Range("BG" & i).Value
Sheet13.Range("BH" & V + 3) = Range("BH" & i).Value
Next j
Next i
x = Sheet12.Range("BK65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("BK" & i).Value, "/")
For j = 0 To UBound(arr)
W = W + 1
Sheet13.Range("BK" & W + 3) = arr(j)
Sheet13.Range("BL" & W + 3) = Range("BL" & i).Value
Sheet13.Range("BM" & W + 3) = Range("BM" & i).Value
Sheet13.Range("BN" & W + 3) = Range("BN" & i).Value
Next j
Next i
x = Sheet12.Range("BK65536").End(xlUp).Row
For i = 4 To x
arr = Split(Range("BK" & i).Value, "/")
For j = 0 To UBound(arr)
Y = Y + 1
Sheet13.Range("BQ" & Y + 3) = arr(j)
Sheet13.Range("BR" & Y + 3) = Range("BR" & i).Value
Sheet13.Range("BS" & Y + 3) = Range("BS" & i).Value
Sheet13.Range("BT" & Y + 3) = Range("BT" & i).Value
Next j
Next i
Sheet13.Select
Range("B4").Select
|
|