Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
replace string | Excel Programming | |||
Replace Hyperlink Addresses Help 'Dim OldStr As String, NewStr As String | Excel Programming | |||
How do I replace last numeric string from a alphanumeric string? | Excel Discussion (Misc queries) | |||
replace in a string | Excel Programming | |||
Substring to replace string | Excel Programming |