网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
08月29日漏签0天
vba吧 关注:17,065贴子:66,767
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 0回复贴,共1页
<<返回vba吧
>0< 加载中...

求教各位,如何提高下列代码的运行速度.

  • 取消只看楼主
  • 收藏

  • 回复
  • 平常心
  • 仗剑天涯
    3
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
Private Sub Command10_Click()
Me.Label3.Caption = Me.Label3.Caption + 1
Dim arr1 As Excel.Range, arr2 As Excel.Range
Dim i As Long, j As Long, k As Long, g As Long
Dim arrsht1 As Excel.Worksheet, arrsht2 As Excel.Worksheet
If dkgzb Is Nothing Then Exit Sub
Me.WindowState = 1
dkapp.WindowState = xlMaximized
On Error GoTo 102
Set arr1 = dkgzb.Application.InputBox("请选择第1列条件数据.", "对比条件列选取", Type:=8)
Set arrsht1 = dkgzb.ActiveSheet
If arr1.Rows.Count > 30000 Then
Set arr1 = arrsht1.Range(arr1(1, 1).Address & ":" & arrsht1.Cells(arr1.SpecialCells(xlCellTypeLastCell).Row, arr1.Columns.Count).Address)
End If
Set arr2 = dkgzb.Application.InputBox("请选择第2列对比数据.", "对比条件列选取", Type:=8)
Set arrsht2 = dkgzb.ActiveSheet
If arr2.Rows.Count > 30000 Then
Set arr2 = arrsht2.Range(arr2(1, 1).Address & ":" & arrsht2.Cells(arr2.SpecialCells(xlCellTypeLastCell).Row, arr2.Columns.Count).Address)
End If
' dkgzb.Application.ScreenUpdating = False
arr1.Interior.ColorIndex = xlNone
arr2.Interior.ColorIndex = xlNone
If arr1.Address = arr2.Address Then '单个区域重复值上色
For i = 1 To arr1.Rows.Count
For j = 1 To arr1.Columns.Count
If dkgzb.Application.WorksheetFunction.CountIf(arr1, arr1(i, j)) > 1 Then arr1(i, j).Interior.ColorIndex = 38
Next
Next
GoTo 102
End If
For i = 1 To arr1.Rows.Count '两个区域标记重复值
For j = 1 To arr1.Columns.Count
For k = 1 To arr2.Rows.Count
For g = 1 To arr2.Columns.Count
If arr1(i, j) = arr2(k, g) And arr1(i, j) <> "" And arr2(k, g) <> "" Then
arr1(i, j).Interior.ColorIndex = 38
arr2(k, g).Interior.ColorIndex = 38
End If
Next g
Next k
Next j
Next i
Me.WindowState = 1
dkapp.WindowState = xlMaximized
102
' dkgzb.Application.ScreenUpdating = True
End Sub


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 0回复贴,共1页
<<返回vba吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示