最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

【實例08-間隔行插入分頁符】Excel表格VBA編程實例 代碼分享

2023-02-25 00:36 作者:凌霄百科_Excel辦公程序  | 我要投稿


Private Sub CommandButton處理_Click()

'判斷工作簿名,工作表名不為空

With ThisWorkbook.Worksheets("操作界面")

? ? ?If Trim(.Cells(2, "C").Value) = "" Or Trim(.Cells(6, "C").Value) = "" Or Trim(.Cells(10, "C").Value) = "" _

? ? ?Or Trim(.Cells(10, "D").Value) = "" Or Trim(.Cells(14, "C").Value) = "" Then

? ? ?MsgBox "參數(shù)不能為空"

? ? ?Exit Sub

? ? ?End If

'On Error GoTo 處理出錯

'定義變量

Dim wbname As String

Dim shname As String

wbname = Trim(.Cells(2, "C").Value)

shname = Trim(.Cells(6, "C").Value)

Dim splitrow As Long

Dim startnum As Long

Dim stopnum As Long

splitrow = Trim(.Cells(14, "C").Value)

startnum = Trim(.Cells(10, "C").Value)

stopnum = Trim(.Cells(10, "D").Value)

End With

'處理表格

With Workbooks(wbname).Worksheets(shname)

Dim i

For i = startnum To stopnum Step splitrow

? ? .HPageBreaks.Add before:=.Cells(i, 1)

Next i

End With

Workbooks(wbname).Save

MsgBox "處理完成"

Workbooks(wbname).Activate

ActiveWindow.WindowState = xlMaximized

Workbooks(wbname).Worksheets(shname).Activate

Workbooks(wbname).Worksheets(shname).Cells(1, 1).Select

Exit Sub

處理出錯:

MsgBox Err.Description

End Sub


【實例08-間隔行插入分頁符】Excel表格VBA編程實例 代碼分享的評論 (共 條)

分享到微博請遵守國家法律
曲周县| 利辛县| 莒南县| 曲水县| 高密市| 梓潼县| 沁水县| 塔城市| 阳江市| 新晃| 松江区| 巴马| 余江县| 博乐市| 萝北县| 乐昌市| 遂宁市| 南投县| 柳河县| 庆阳市| 略阳县| 繁峙县| 岳池县| 桐梓县| 灵丘县| 昌宁县| 江油市| 商丘市| 信宜市| 金寨县| 寿宁县| 吐鲁番市| 团风县| 牟定县| 博罗县| 遂平县| 阳新县| 中山市| 枞阳县| 苏州市| 平和县|