五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

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

實(shí)例19-間隔指定行數(shù)插入空行,實(shí)例20-提取多行多列 Excel表格VBA編程實(shí)例 代碼分享

2023-03-02 22:21 作者:凌霄百科_Excel辦公程序  | 我要投稿

實(shí)例19-間隔指定行數(shù)插入空行

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 處理出錯(cuò)

'定義變量

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 = stopnum To startnum Step splitrow * (-1)

.Rows(i).Insert

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í)例20-提取多行多列

Private Sub CommandButton提取列_Click()

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

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

If Trim(.Cells(2, "C").Value) = "" Or Trim(.Cells(6, "C").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)

End With

'清除提取結(jié)果

With ThisWorkbook.Worksheets("提取結(jié)果")

.UsedRange.ClearFormats

.UsedRange.ClearContents

End With

'處理表格

With Workbooks(wbname).Worksheets(shname)

'循環(huán)

Dim i, icount

Dim imax As Long

imax = ThisWorkbook.Worksheets("提取行列號(hào)").Cells(1, 10000).End(xlToLeft).Column

icount = 1

For i = 1 To imax

If ThisWorkbook.Worksheets("提取行列號(hào)").Cells(1, i) <> "" Then

.Columns(CLng(ThisWorkbook.Worksheets("提取行列號(hào)").Cells(1, i))).Copy ThisWorkbook.Worksheets("提取結(jié)果").Columns(icount)

icount = icount + 1

End If

Next i

End With

MsgBox "處理完成"

ThisWorkbook.Worksheets("提取結(jié)果").Activate

Exit Sub

處理出錯(cuò):

MsgBox Err.Description

End Sub

Private Sub CommandButton提取行_Click()

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

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

If Trim(.Cells(2, "C").Value) = "" Or Trim(.Cells(6, "C").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)

End With

'清除提取結(jié)果

With ThisWorkbook.Worksheets("提取結(jié)果")

.UsedRange.ClearFormats

.UsedRange.ClearContents

End With

'處理表格

With Workbooks(wbname).Worksheets(shname)

'循環(huán)

Dim i, icount

Dim imax As Long

imax = ThisWorkbook.Worksheets("提取行列號(hào)").Cells(1000000, 1).End(xlUp).Row

icount = 1

For i = 1 To imax

If ThisWorkbook.Worksheets("提取行列號(hào)").Cells(i, 1) <> "" Then

.Rows(CLng(ThisWorkbook.Worksheets("提取行列號(hào)").Cells(i, 1))).Copy ThisWorkbook.Worksheets("提取結(jié)果").Rows(icount)

icount = icount + 1

End If

Next i

End With

MsgBox "處理完成"

ThisWorkbook.Worksheets("提取結(jié)果").Activate

Exit Sub

處理出錯(cuò):

MsgBox Err.Description

End Sub


實(shí)例19-間隔指定行數(shù)插入空行,實(shí)例20-提取多行多列 Excel表格VBA編程實(shí)例 代碼分享的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
高安市| 宝兴县| 南雄市| 陇西县| 大宁县| 广元市| 兴文县| 金山区| 高州市| 长丰县| 巩义市| 北京市| 台中市| 大姚县| 增城市| 盱眙县| 平阴县| 高州市| 湟中县| 益阳市| 鄂尔多斯市| 博客| 罗甸县| 米易县| 砀山县| 泗洪县| 凤阳县| 安义县| 休宁县| 安平县| 剑阁县| 黎川县| 洞头县| 庆安县| 平顺县| 永州市| 清水县| 牡丹江市| 九台市| 五莲县| 全州县|