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

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

實例21-刪除工作簿中多個工作表,實例22-提取多個工作表合并為一個工作表

2023-03-04 23:10 作者:凌霄百科_Excel辦公程序  | 我要投稿

實例21-刪除工作簿中多個工作表

Dim wbname As String

Private Sub CommandButton獲取_Click()

'獲取工作簿中包含的工作表

With ThisWorkbook.Worksheets("名稱列表")? '清除原列表數(shù)據(jù)

? ? .Columns(1).ClearFormats

? ? .Columns(1).ClearContents

? ? .Columns(2).ClearFormats

? ? .Columns(2).ClearContents

End With

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

If .Cells(2, "C").Value <> "" Then

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

Else

MsgBox "請輸入工作簿名稱(包含擴(kuò)展名)"

Exit Sub

End If

End With

Dim i As Integer

For i = 1 To Workbooks(wbname).Worksheets.Count

? ? ThisWorkbook.Worksheets("名稱列表").Cells(i, 1).Value = Workbooks(wbname).Worksheets(i).Name

Next i

ThisWorkbook.Worksheets("名稱列表").Activate

End Sub




Private Sub CommandButton刪除_Click()

Application.DisplayAlerts = False

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

If .Cells(2, "C").Value <> "" Then

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

Else

MsgBox "請輸入工作簿名稱(包含擴(kuò)展名)"

Exit Sub

End If

End With

With ThisWorkbook.Worksheets("名稱列表")

? ? Dim i As Long

? ? Dim imax As Long

? ? imax = .Cells(1000000, 1).End(xlUp).Row

? ? For i = 1 To imax

? ? ? ? If .Cells(i, 1).Value <> "" And .Cells(i, 2).Value <> "" Then

? ? ? ? ? ? Workbooks(wbname).Worksheets(CStr(.Cells(i, 1).Value)).Delete

? ? ? ? End If

? ? Next i

? ? Workbooks(wbname).Save

? ? MsgBox "處理完成"

End With

Application.DisplayAlerts = True

End Sub

實例22-提取多個工作表合并為一個工作表

Dim wbname As String

Private Sub CommandButton獲取_Click()

'獲取工作簿中包含的工作表

With ThisWorkbook.Worksheets("名稱列表")? '清除原列表數(shù)據(jù)

? ? .Columns(1).ClearFormats

? ? .Columns(1).ClearContents

End With

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

If .Cells(2, "C").Value <> "" Then

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

Else

MsgBox "請輸入工作簿名稱(包含擴(kuò)展名)"

Exit Sub

End If


End With

Dim i As Integer

For i = 1 To Workbooks(wbname).Worksheets.Count

? ? ThisWorkbook.Worksheets("名稱列表").Cells(i, 1).Value = Workbooks(wbname).Worksheets(i).Name

Next i

ThisWorkbook.Worksheets("名稱列表").Activate

End Sub





Private Sub CommandButton提取_Click()

With ThisWorkbook.Worksheets("提取結(jié)果")? '清除原列表數(shù)據(jù)

? ? .UsedRange.ClearFormats

? ? .UsedRange.ClearContents

End With

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

If .Cells(2, "C").Value <> "" Then

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

Else

MsgBox "請輸入工作簿名稱(包含擴(kuò)展名)"

Exit Sub

End If

Dim extractrange As String

If .Cells(6, "C").Value <> "" Then

? ? extractrange = .Cells(6, "C").Value

Else

MsgBox "請輸入提取區(qū)域地址"

Exit Sub

End If

End With

Dim addrow As Long


With ThisWorkbook.Worksheets("名稱列表")

? ? Dim i As Long

? ? Dim imax As Long

? ? imax = .Cells(1000000, 1).End(xlUp).Row

? ? For i = 1 To imax

? ? ? ? If .Cells(i, 1).Value <> "" Then

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

? ? ? ? ? ? addrow = .UsedRange.Cells(.UsedRange.Cells.Count).Row + 2

? ? ? ? End With

? ? ? ? ? ? Workbooks(wbname).Worksheets(CStr(.Cells(i, 1).Value)).Range(extractrange).Copy ThisWorkbook.Worksheets("提取結(jié)果").Cells(addrow, 1)

? ? ? ? End If

? ? Next i

? ? MsgBox "處理完成"

End With

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

End Sub


實例21-刪除工作簿中多個工作表,實例22-提取多個工作表合并為一個工作表的評論 (共 條)

分享到微博請遵守國家法律
榆树市| 扶余县| 酉阳| 蒲江县| 醴陵市| 侯马市| 谢通门县| 钟山县| 武汉市| 五常市| 莆田市| 芜湖县| 连南| 宁化县| 南汇区| 新闻| 瑞安市| 台北县| 唐河县| 马关县| 白水县| 万州区| 洪雅县| 若尔盖县| 临汾市| 克什克腾旗| 嘉鱼县| 安吉县| 湛江市| 弥勒县| 富蕴县| 蒙自县| 微山县| 雷波县| 广宁县| 蕉岭县| 和平县| 马山县| 于田县| 嘉荫县| 舟曲县|