首页 > 社交 > 科普中国

技巧篇:常用的vba代码汇总

常驻编辑 科普中国 2022-06-09 坐标轴   大前提   间距   数组   图表   模块   指标   常用   代码   业务   标题   技巧   目录
<= UBound(tmp_array) tmp_c = tmp_array(j) i = 2 Select Case tmp_c Case Is < 3: nr = sh.UsedRange.Rows.Count Do While i <= nr If i = 2 Then ini_str = sh.Cells(i, tmp_c) With sh.Rows(i + 1) .Insert Shift:=xlDown sh.Cells(i + 1, tmp_c + 2) = sh.Cells(i, tmp_c + 2) sh.Cells(i + 1, tmp_c + 3) = sh.Cells(i, tmp_c + 3) sh.Cells(i + 1, tmp_c + 4) = sh.Cells(i, tmp_c + 4) sh.Range(Cells(i, tmp_c + 2), Cells(i, tmp_c + 4)).Clear End With nr = nr + 1 i = i + 1 Else tmp_str = sh.Cells(i, tmp_c) If tmp_str = ini_str Then sh.Range(Cells(i, tmp_c), Cells(i, tmp_c + 1)).Clear Else ini_str = tmp_str With sh.Rows(i + 1) .Insert Shift:=xlDown sh.Cells(i + 1, tmp_c + 2) = sh.Cells(i, tmp_c + 2) sh.Cells(i + 1, tmp_c + 3) = sh.Cells(i, tmp_c + 3) sh.Cells(i + 1, tmp_c + 4) = sh.Cells(i, tmp_c + 4) sh.Range(Cells(i, tmp_c + 2), Cells(i, tmp_c + 4)).Clear End With nr = nr + 1 i = i + 1 End If End If i = i + 1 Loop Case Else: nr = sh.UsedRange.Rows.Count For k = 2 To nr If sh.Cells(k, tmp_c - 1) <> "" Then i = k + 1 With sh.Cells(i, tmp_c) ini_str = .Value If .Offset(1, 0) = "" Then tmp_end = i Else tmp_end = .End(xlDown).Row End If End With Do While i <= tmp_end tmp_str = sh.Cells(i, tmp_c) If tmp_str = ini_str And i = k + 1 Then With sh.Rows(i + 1) .Insert Shift:=xlDown sh.Cells(i + 1, tmp_c + 1) = sh.Cells(i, tmp_c + 1) sh.Cells(i + 1, tmp_c + 2) = sh.Cells(i, tmp_c + 2) sh.Range(Cells(i, tmp_c + 1), Cells(i, tmp_c + 2)).Clear End With i = i + 1 nr = nr + 1 tmp_end = tmp_end + 1 Else If tmp_str = ini_str Then sh.Cells(i, tmp_c).Clear Else If tmp_str <> "" Then ini_str = tmp_str With sh.Rows(i + 1) .Insert Shift:=xlDown sh.Cells(i + 1, tmp_c + 1) = sh.Cells(i, tmp_c + 1) sh.Cells(i + 1, tmp_c + 2) = sh.Cells(i, tmp_c + 2) sh.Range(Cells(i, tmp_c + 1), Cells(i, tmp_c + 2)).Clear End With nr = nr + 1 i = i + 1 tmp_end = tmp_end + 1 End If End If End If i = i + 1 Loop k = i - 1 End If Next End Select j = j + 1 Loop End Sub Sub group() Dim sht As Worksheet Dim row_start%, row_end% Dim target_column Set sht = Sheets("structure") row_start = 2 target_column = "D" ' row_end = sht.Cells(1048576, target_column).End(xlUp).Row + 1 row_end = sht.UsedRange.Rows.Count sht.Cells.ClearOutline Dim i Dim refer_row% i = row_start refer_row = row_start Do While i <= row_end If Cells(i, 1) <> "" Then With Range(Cells(i, 1), Cells(i, 5)) .Interior.Color = RGB(208, 206, 206) .Font.Color = RGB(0, 0, 0) .Font.Bold = True With .Borders(xlEdgeTop) .LineStyle = xlDash .Color = RGB(166, 166, 166) End With With .Borders(xlEdgeBottom) .LineStyle = xlDash .Color = RGB(166, 166, 166) End With End With End If If Cells(i, 3)

相关阅读:

  • 魔幻工厂一字裤天猫旗舰店正式开售!三重好礼买到爽
  • 马桶两边留多少间距最为合适
  • 美国InfoComm
  • 班凯罗:若塔图姆在总决赛上出手更多中距离
  • 自驾游组队要注意的问题
  • 栏杆立杆间距规范要求 栏杆规范要求 栏杆长度规范 栏
  • 脸上有这5个特征,就是年纪越大越耐看的“抗老脸”,全中
  • 鼻头千万别再乱动了
  • 事关国庆假期出游,文旅部提醒!
  • 一个人开三辆车?奔驰测试无人驾驶卡车车队
    • 网站地图 |
    • 声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。文章内容仅供参考,不做权威认证,如若验证其真实性,请咨询相关权威专业人士。