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

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

【實(shí)例09-刪除指定文本行】Excel表格VBA編程實(shí)例 代碼分享

2023-02-25 14:57 作者:凌霄百科_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(18, "C").Value) = "" Or Trim(.Cells(14, "C").Value) = "" Or Trim(.Cells(14, "D").Value) = "" Then

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

? ? ?Exit Sub

? ? ?End If


On Error GoTo 處理出錯(cuò)

'定義變量

Dim wbname As String

Dim shname As String

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

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

Dim matchcolumn As Long

Dim startnum As Long

Dim stopnum As Long

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

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

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

Dim matchtext As String

matchtext = Trim(.Cells(18, "C").Value)

End With

'處理表格

With Workbooks(wbname).Worksheets(shname)

'循環(huán)判斷(反向)

Dim i

For i = stopnum To startnum Step -1

? ? If .Cells(i, matchcolumn) <> "" And .Cells(i, matchcolumn) = matchtext Then

? ? ? ? .Rows(i).Delete

? ? End If

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

處理出錯(cuò):

MsgBox Err.Description

End Sub



【實(shí)例09-刪除指定文本行】Excel表格VBA編程實(shí)例 代碼分享的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
西充县| 安塞县| 鲁山县| 大余县| 秦安县| 南召县| 漠河县| 乌兰县| 砚山县| 鹤庆县| 陵水| 马尔康县| 汶川县| 连城县| 绥中县| 桑植县| 肥西县| 化德县| 嘉峪关市| 麻城市| 方正县| 崇信县| 新化县| 吉安县| 新津县| 通化市| 陕西省| 资源县| 静安区| 开远市| 虹口区| 泸西县| 鄂托克前旗| 伊金霍洛旗| 普洱| 平阴县| 栾川县| 高雄市| 舟山市| 扶绥县| 海原县|