国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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ó)家法律
邢台县| 廊坊市| 安远县| 屏东县| 潮安县| 恩平市| 广安市| 玛沁县| 阆中市| 文水县| 泰和县| 莲花县| 万盛区| 河池市| 临桂县| 田林县| 隆安县| 恩施市| 淄博市| 盱眙县| 平定县| SHOW| 平安县| 永宁县| 石泉县| 自治县| 易门县| 沙洋县| 安图县| 北川| 屏山县| 砚山县| 神农架林区| 嘉义市| 墨玉县| 个旧市| 永泰县| 延川县| 厦门市| 安西县| 拉萨市|