2

So I have found and modified a macro that fits my needs, however there is one limitation. I am building a macro to search medical payment data for specific diagnosis codes and procedure codes. In the project I am currently working on there are only 14 diagnosis codes, so I was able to put this directly into the VBA. However, there are over 800 procedure codes which I cannot fit into the VBA. I was able to do a seperate VBA step to bring in a table with this data, but I cant seem to get it set up to search against the table. But that being said, what is the best way to run this VBA search for such a large number of items?

Sub PROCEDURE_1_search()
Dim FirstAddress As String
Dim MySearch As Variant
Dim myColor As Variant
Dim Rng As range
Dim I As Long

MySearch = Array("412", "4100", "4101", "4102", "4103",...) <-- have over 800

  With Sheets("All Claims by Date of Service").range("G5:G55000")
    For I = LBound(MySearch) To UBound(MySearch)
       Set Rng = .Find(What:=MySearch(I), _
                        After:=.Cells(.Cells.Count), _
                        LookIn:=xlValues, _
                        LookAt:=xlPart, _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlNext, _
                        MatchCase:=False)
        If Not Rng Is Nothing Then
            FirstAddress = Rng.Address
            Do
                With ActiveSheet.range("B" & Rng.Row & ":O" & Rng.Row)
                    .Font.ColorIndex = 1
                    .Interior.ColorIndex = 4
                End With
                Set Rng = .FindNext(Rng)
            Loop While Not Rng Is Nothing And Rng.Address <> FirstAddress
        End If
    Next I
End With
End Sub

I might be coming up with an answer and not asking the right questions. Please let me know if there is anything I can clarify and thank you in advance for any assistance.

-Ryan

4

2 に答える 2

2

配列を検索するには、範囲を反復するのではなく、データをバリアント配列にダンプすることをお勧めします。そうすれば、コードとシート、特に書式設定を元に戻すトラフィックが削減されます。フォーマットはとにかく高価です。あなたの場合、月がかかるようです..

手順は次のとおりです (コードではありません。コードが必要な場合は、これらのサンプルを参照してください)。

  1. データをバリアント配列に転置する
  2. VBAコードで好きなように検索
  3. 場所(範囲)にデータバックをダンプします
  4. フォーマット(範囲)
于 2013-02-27T03:57:17.447 に答える
1

あなたの例ではAutoFilter、このように使用して、列 B から列 O までの行を強調表示できます。ここで、G は4101-41031 回のショットで間にあります (つまり、4 つの条件が 1 つの条件に一致します)。マイナーな適応は、スタンドライン 412 などのさまざまな基準に対してこのコード ブロックを呼び出すことです。

Sub Smaller()
Dim rng1 As Range
Set rng1 = Sheets("All Claims by Date of Service").Range("$G$5:$G$55000")
With rng1
   .AutoFilter Field:=1, Criteria1:=">=4100", Operator:=xlAnd, Criteria2:="<=4103"
       .Offset(0, -6).Resize(rng1.Rows.Count, 14).Font.ColorIndex = 1
       .Offset(0, -6).Resize(rng1.Rows.Count, 14).Interior.ColorIndex = 4
End With
Sheets(rng1.Parent.Name).AutoFilterMode = False
End Sub
于 2013-02-27T04:13:08.347 に答える