/
LIB_Substitutes.bas
33 lines (25 loc) · 1.05 KB
/
LIB_Substitutes.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Attribute VB_Name = "LIB_Substitutes"
Function SuperSubV(strOldText As String, ByVal Rng1 As Range, ByVal rng2 As Range) As String
Dim cel As Range
Dim strMyChar As String, strMyReplace As String
For Each cel In Rng1
strMyChar = cel.Value
strMyReplace = cel.Offset(0, rng2.Column - Rng1.Column).Value
' Next line does not work.
'It would require a VBA version of Excel's SUBSTITUTE to work
strOldText = Replace(strOldText, strMyChar, strMyReplace)
Next cel
SuperSubV = strOldText
End Function
Function SuperSubH(strOldText As String, ByVal Rng1 As Range, ByVal rng2 As Range) As String
Dim cel As Range
Dim strMyChar As String, strMyReplace As String
For Each cel In Rng1
strMyChar = cel.Value
strMyReplace = cel.Offset(rng2.Row - Rng1.Row, 0).Value
' Next line does not work.
'It would require a VBA version of Excel's SUBSTITUTE to work
strOldText = Replace(strOldText, strMyChar, strMyReplace)
Next cel
SuperSubH = strOldText
End Function