Replace string
Hi
For speed I am trying to use Replace, on a range object, to insert a string
but the replacement string is displayed as a single character whereas it
should be 2.
Say kycode = "01" this code displays it correctly as 01
Dim kycode As String
Dim tbl as Range, rng as Range
Dim finalrecords as Long
Range("H:H").NumberFormat = "@"
If Not kycode = "" Then
Set tbl = Range("H2:H" & finalrecords + 1)
For Each rng In tbl
rng = kycode '''=01
Next
End If
This code displays keycode as 1
Range("H:H").NumberFormat = "@"
If Not kycode = "" Then
Set tbl = Range("H2:H" & finalrecords + 1)
tbl.Replace "", kycode, xlWhole, xlByColumns, False '''=1
End If
The benefits of Replace in terms of speed are worthwhile considering the
number of records to search. Any help would be appreciated.
Geoff
|