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

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

實例37-多個工作表指定區(qū)域最大最小值,實例38-多個工作表指定區(qū)域求和平均計數(shù)

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

實例37-多個工作表指定區(qū)域最大最小值


Private Sub CommandButton處理_Click()

Dim wbname As String

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

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

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

Else

MsgBox "請輸入工作簿名稱(包含擴(kuò)展名),查找區(qū)域,查找值,替換值"

Exit Sub

End If

End With

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

Dim i As Long

Dim imax As Long

Dim shtname As String

Dim findrange As String

Dim maxdata As Double

Dim mindata As Double

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

For i = 1 To imax

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

shtname = .Cells(i, 1).Value

findrange = .Cells(i, 2).Value

With Workbooks(wbname).Worksheets(shtname)

Dim cellitem

Dim a1 As Integer

a1 = 0

For Each cellitem In .Range(findrange)


If cellitem.Value <> "" And IsNumeric(cellitem.Value) = True Then

If a1 = 0 Then

maxdata = cellitem.Value

mindata = cellitem.Value

a1 = 1

Else

If cellitem.Value > maxdata Then

maxdata = cellitem.Value

End If

If cellitem.Value < mindata Then

mindata = cellitem.Value

End If

End If


End If

Next

End With

End If

.Cells(i, 3).Value = maxdata

.Cells(i, 4).Value = mindata

Next i

.Activate

End With

MsgBox "處理完成"

End Sub

Private Sub CommandButton獲取_Click()

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

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

.Columns(1).ClearFormats

.Columns(1).ClearContents

End With

Dim wbname As String

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

實例38-多個工作表指定區(qū)域求和平均計數(shù)


Private Sub CommandButton處理_Click()

Dim wbname As String

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

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

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

Else

MsgBox "請輸入工作簿名稱(包含擴(kuò)展名),查找區(qū)域,查找值,替換值"

Exit Sub

End If

End With

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

Dim i As Long

Dim imax As Long

Dim shtname As String

Dim findrange As String

Dim sumdata As Double

Dim countdata As Double

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

For i = 1 To imax

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

shtname = .Cells(i, 1).Value

findrange = .Cells(i, 2).Value

With Workbooks(wbname).Worksheets(shtname)

sumdata = 0

countdata = 0

Dim cellitem

For Each cellitem In .Range(findrange)


If cellitem.Value <> "" And IsNumeric(cellitem.Value) = True Then

sumdata = sumdata + cellitem.Value

countdata = countdata + 1


End If

Next

End With

End If

If sumdata = 0 And countdata = 0 Then

.Cells(i, 3).Value = ""

.Cells(i, 4).Value = ""

.Cells(i, 5).Value = ""

Else

.Cells(i, 3).Value = sumdata

.Cells(i, 4).Value = countdata

.Cells(i, 5).Value = sumdata / countdata

End If

Next i

.Activate

End With

MsgBox "處理完成"

End Sub

Private Sub CommandButton獲取_Click()

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

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

.Columns(1).ClearFormats

.Columns(1).ClearContents

End With

Dim wbname As String

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



實例37-多個工作表指定區(qū)域最大最小值,實例38-多個工作表指定區(qū)域求和平均計數(shù)的評論 (共 條)

分享到微博請遵守國家法律
肥西县| 徐州市| 易门县| 奎屯市| 鞍山市| 米易县| 淮滨县| 图木舒克市| 青岛市| 巴南区| 郧西县| 阜阳市| 长垣县| 祁门县| 宜黄县| 阳曲县| 武城县| 毕节市| 乌拉特前旗| 玛沁县| 奈曼旗| 黔东| 越西县| 喜德县| 汕尾市| 武邑县| 锦州市| 曲靖市| 中西区| 新丰县| 七台河市| 吉林省| 汕尾市| 商丘市| 循化| 潜山县| 静乐县| 南召县| 芦溪县| 关岭| 曲水县|