Permalink
Browse files

Edits to Regex syntax; fixed Tbl_lookup

  • Loading branch information...
1 parent 558d542 commit 2dc7cd0a42375cf16dfa41245fe21b2984d0dc2d @shapiromatron committed Sep 9, 2011
Showing with 13 additions and 11 deletions.
  1. +2 −0 .gitignore
  2. +4 −4 VBA/k_Regex.bas
  3. +7 −7 VBA/z_Excel.bas
View
2 .gitignore
@@ -0,0 +1,2 @@
+
+VBA.pnproj
View
8 VBA/k_Regex.bas
@@ -45,8 +45,8 @@ Public Function RegexSearch(ByVal Pattern As String, _
' attributes. See:
' http://msdn.microsoft.com/en-us/library/ms974619.aspx#scripting12_topic4
'
- Dim re As New RegExp
-
+ Dim re As Object
+ Set re = CreateObject("vbscript.regexp")
With re
.Pattern = Pattern
.IgnoreCase = IgnoreCase
@@ -90,8 +90,8 @@ Public Function RegexReplace(ByVal Pattern As String, _
' in `SourceString`. If `Pattern` is not found, returns `SourceString`
' as-is.
'
- Dim re As New RegExp
-
+ Dim re As Object
+ Set re = CreateObject("vbscript.regexp")
With re
.Pattern = Pattern
.IgnoreCase = IgnoreCase
View
14 VBA/z_Excel.bas
@@ -607,7 +607,7 @@ Public Function Tbl_Lookup(Tbl As Range, _
' Debug.Print "AllMatch: " & CStr(eachItem)
' Next
'---------------------------------------------------------------------------------------------------------
- Dim eachItem As Variant, eachRow As Variant
+ Dim eachItem As Variant, EachRow As Variant
Dim ColName() As String, MatchCriteria() As String, ColNum() As Integer
Dim SplitVal2() As String, i As Integer, ReturnCol As Integer
Dim MatchFound As Boolean
@@ -629,10 +629,10 @@ Public Function Tbl_Lookup(Tbl As Range, _
ReturnCol = Range_FindMatch(ReturnColumnName, Tbl.Rows(1).Cells)
'FIND MATCHES IN TABLE
- For Each eachRow In Tbl.Columns(1).Cells 'Search each row in table
+ For Each EachRow In Tbl.Columns(1).Cells 'Search each row in table
MatchFound = True
For i = 0 To UBound(SearchCriteria(0)) 'Search each match criteria
- If MatchCriteria(i) <> Tbl.Cells(eachRow.Row, ColNum(i)) Then
+ If MatchCriteria(i) <> EachRow.Offset(0, ColNum(0) - 1).Value Then
MatchFound = False
Exit For
End If
@@ -641,15 +641,15 @@ Public Function Tbl_Lookup(Tbl As Range, _
' FirstMatch = 1, FirstMatchRow = 2, AllMatch = 3, AllMatchRows = 4
Select Case LookupReturn
Case 1
- Tbl_Lookup = Tbl.Cells(eachRow.Row, ReturnCol).Value
+ Tbl_Lookup = EachRow.Offset(0, ReturnCol - 1).Value
Exit Function
Case 2
- Tbl_Lookup = eachRow.Row
+ Tbl_Lookup = EachRow.Row
Exit Function
Case 3
- ReturnCollection.Add Tbl.Cells(eachRow.Row, ReturnCol).Value
+ ReturnCollection.Add EachRow.Offset(0, ReturnCol - 1).Value
Case 4
- ReturnCollection.Add eachRow.Row
+ ReturnCollection.Add EachRow.Row
End Select
End If
Next

0 comments on commit 2dc7cd0

Please sign in to comment.