返回列表 上一主題 發帖

[發問] 轉換文字形式搜尋

本帖最後由 samwang 於 2021-9-10 14:46 編輯

回復 30# wayne0303


R = Range("f65536").End(3).Row >>這是表格起始位置?所以您這個代碼沒有設定表格搜尋範圍了?
Arr = Range("a1:a" & [a65536].End(3).Row)>>這是來源配對檔位置?   
>> #29 程式碼,只有針對你提到"我的欄列都會(不對等的)增加" 做修改如下,還有比對時一小部分新增,已有寫註解了,請自行研究一下,謝謝

Application.ScreenUpdating = False: Application.DisplayAlerts = False
'FPath = ThisWorkbook.Path  '本檔案的路徑
'Set WB = Workbooks.Open(FPath & "\統計表.xlsx") '開啟本檔案路徑下的統計表
'''針對"我的欄列都會(不對等的)增加"的處理,

With Sheets(1)
    If .FilterMode Then .ShowAllData
    R = Range("f65536").End(3).Row  'F欄最後一列
    C = Rows("3:" & R).Find("*", searchorder:=xlByColumns, SearchDirection:=xlPrevious).Column '找到最後一欄
    Arr = Range([f1], Cells(R, C)) '資料裝入陣列
    For i = 1 To UBound(Arr)
        If InStr(Arr(i, 1), "右螺") Then
            For j = 1 To UBound(Arr, 2)
                T = Arr(i + 2, j): If T = "" Then GoTo 95
                xD(T & "_1") = Arr(i + 1, j)   '右螺旋資料裝到字典
95:         Next
        ElseIf InStr(Arr(i, 1), "左螺") Then
            For j = 1 To UBound(Arr, 2)
                T = Arr(i + 2, j): If T = "" Then GoTo 96
                xD(T & "_2") = Arr(i + 1, j)    '左螺旋資料裝到字典
96:         Next
        ElseIf InStr(Arr(i, 1), "平") Then
            For j = 1 To UBound(Arr, 2)
                T = Arr(i + 2, j): If T = "" Then GoTo 97
                xD(T & "_3") = Arr(i + 1, j)    '平彎資料裝到字典
97:         Next
        End If
    Next
End With
'WB.Close   '關閉統計表

'下面的上次的一樣,只有新增如下

Arr = Range("a1:a" & [a65536].End(3).Row) '要被比對的資料
For i = 1 To UBound(Arr)
    If Arr(i, 1) = "" Then GoTo 98 '新增:當A欄的儲存格無資料不做動作
    If Left(Arr(i, 1), 1) = "L" Or Left(Arr(i, 1), 1) = "R" Then 'A欄儲存格的第1個字"L" "R"才動作

        w1 = Left(Arr(i, 1), 1): w2 = Mid(Arr(i, 1), 2, 1)
        If Asc(w1) > 64 And Asc(w1) < 123 And Asc(w2) > 64 And Asc(w2) < 123 Then
....
...

TOP

        靜思自在 : 難行能行,難捨能捨,難為能為,才能昇華自我的人格。
返回列表 上一主題