|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 huangfanzhen 于 2016-11-18 20:32 编辑
代码如下,由于大量使用cells,性能很差,哪位大神给个提示。
如何用数组,批量读取sheet1,处理完成后写入sheet1
由于A列数据会非常多 大概几万行,实例表格仅仅选用了一部分
非常感谢
- Sub 分词()
- rA = Cells(2, 6)
- rD = Cells(2, 7)
- rN = Cells(2, 14)
- For a = 2 To rA
- Cells(a, 3) = ""
- Cells(a, 2) = LCase(Cells(a, 1))
- For i = 2 To rD
- cG = LCase(Cells(i, 4))
- q = IIf(InStr(cG, "*"), 1, 0)
- If q = 0 Then
- t = IIf(InStr(Cells(a, 2), cG), 1, 0)
- If t > 0 Then
- Cells(a, 3) = Cells(a, 3) & "[" & Cells(i, 5) & "]"
- End If
- Cells(a, 2) = Replace(Cells(a, 2), cG, "|")
- Else
- starP = InStr(cG, "*")
- starL = Len(cG)
- strL = Left(cG, starP - 1)
- strR = Right(cG, starL - starP)
- zzL = InStr(Cells(a, 2), strL)
- zzR = InStrRev(Cells(a, 2), strR)
- zz = zzL * zzR
- If zz <> 0 Then
- If zzL < zzR Then
- Cells(a, 3) = Cells(a, 3) & "[" & Cells(i, 5) & "]"
- Cells(a, 2) = Replace(Cells(a, 2), strL, "|")
- Cells(a, 2) = Replace(Cells(a, 2), strR, "|")
- End If
- End If
- End If
- Next
- Cells(a, 8) = ""
- For fLA = 2 To rN
- hbl = InStr(Cells(a, 3), Cells(fLA, 10))
- If hbl <> 0 Then
- If hbDLq <> Cells(fLA, 12) Then
- Cells(a, 8) = Cells(a, 8) & Cells(fLA, 11)
- hbDLq = Cells(fLA, 12)
- End If
- End If
- Next
- Next
- End Sub
复制代码
|
|