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

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

【實例12-去除重復(fù)】Excel表格VBA編程實例 代碼分享

2023-02-26 00:39 作者:凌霄百科_Excel辦公程序  | 我要投稿


Private Sub CommandButton去除重復(fù)_Click()

'清除處理結(jié)果數(shù)據(jù)

With ThisWorkbook.Worksheets("處理結(jié)果")

? ? .UsedRange.ClearFormats

? ? .UsedRange.ClearContents

End With

'判斷輸入了區(qū)域參數(shù)

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

? ? ?If Trim(.Cells(2, "C").Value) = "" Then

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

? ? ?Exit Sub

? ? ?End If


On Error GoTo 處理出錯

'定義變量

Dim filterrange As String

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

End With

'循環(huán)篩選,添加到數(shù)組,重復(fù)的不添加

Dim item_array() As String

Dim item_count As Long

With ThisWorkbook.Worksheets("原數(shù)據(jù)")

Dim itemcell

For Each itemcell In .Range(filterrange)

? ? If itemcell <> "" Then

? ? ? ? If item_count = 0 Then

? ? ? ? ReDim Preserve item_array(item_count)

? ? ? ? item_array(item_count) = itemcell.Value

? ? ? ? item_count = item_count + 1

? ? ? ? Else

? ? ? ? ? ? If checkrepeatarrayfun(item_array, itemcell.Value) = False Then

? ? ? ? ? ? ? ? ReDim Preserve item_array(item_count)

? ? ? ? ? ? ? ? item_array(item_count) = itemcell.Value

? ? ? ? ? ? ? ? item_count = item_count + 1

? ? ? ? ? ? End If

? ? ? ? End If

? ? End If

Next

End With

'顯示數(shù)組中的結(jié)果(非重復(fù)數(shù)據(jù))

If item_count > 0 Then

With ThisWorkbook.Worksheets("處理結(jié)果")

Dim i

? ? For i = 0 To UBound(item_array)

? ? ? ? .Cells(i + 1, 1).Value = item_array(i)

? ? Next i

.Activate

.Cells(1, 1).Select

End With

End If

Exit Sub

處理出錯:

MsgBox Err.Description

End Sub


Function checkrepeatarrayfun(ByVal checkarray, ByVal checkdata) As Boolean? '檢查數(shù)組是否有指定值

On Error GoTo checkerror

checkrepeatarrayfun = False

? ? If IsArray(checkarray) = True Then

? ? ? ? Dim check_i

? ? ? ? For check_i = 0 To UBound(checkarray)

? ? ? ? ? ? If checkarray(check_i) = checkdata Then

? ? ? ? ? ? ? ? checkrepeatarrayfun = True

? ? ? ? ? ? ? ? Exit Function

? ? ? ? ? ? End If

? ? ? ? Next check_i

? ? End If

checkerror:

checkrepeatarrayfun = False

End Function


【實例12-去除重復(fù)】Excel表格VBA編程實例 代碼分享的評論 (共 條)

分享到微博請遵守國家法律
芷江| 罗江县| 衢州市| 涿鹿县| 丽水市| 沿河| 枝江市| 延寿县| 屯门区| 高陵县| 湖口县| 北票市| 乐至县| 临颍县| 会宁县| 广饶县| 惠安县| 北川| 招远市| 高邑县| 镶黄旗| 长岭县| 上蔡县| 鄱阳县| 宁夏| 高碑店市| 新化县| 疏勒县| 固镇县| 宜兰县| 怀仁县| 峡江县| 新干县| 海原县| 永靖县| 宁夏| 双牌县| 武陟县| 新余市| 枣庄市| 辽宁省|