usopyon (owner)

Revisions

gist: 59435 Download_button fork
public
Description:
serial_replace for excel vba
Public Clone URL: git://gist.github.com/59435.git
Embed All Files: show embed
Text only #
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
Sub serial_replace()
 
    For i = 1 To 10
        If 0 = my_replace(i) Then Exit For
    Next i
    
End Sub
 
Function my_replace(i)
 
    sheetname = "table"
    target_raw = 1
    replace_raw = 2
 
    If Sheets(sheetname).Cells(i, target_raw).Value = "" Then
        my_replace = 0
    Else
        Selection.Replace _
            What:=Sheets(sheetname).Cells(i, target_raw).Value, _
            Replacement:=Sheets(sheetname).Cells(i, replace_raw).Value, _
            LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
       my_replace = 1
    End If
 
End Function