Hi all
I would like to search and replace for leading apostrophes. I have two pieces of code. The first recognizes the leading apostrophe but is slow in execution (loop through cells in range). The second is fast but ignores the apostrophe.
Code 1:
Code 2:
Essentially, I am looking for a macro that runs over a fairly large range in a worksheet (~ 10,000 cells) and replace any leading apostrophes/high commas whilst minimizing runtime. I am not sure I can avoid addressing each cell individually but hoping there is another way.
Thank in advance
I would like to search and replace for leading apostrophes. I have two pieces of code. The first recognizes the leading apostrophe but is slow in execution (loop through cells in range). The second is fast but ignores the apostrophe.
Code 1:
VBA Code:
Sub RemoveApostrophe()
For Each cell In Selection
cell.Value = Replace(cell.Value, "'", "")
Next cell
End Sub
Code 2:
Code:
Sub FindReplaceAll()
Dim sht As Worksheet
Dim fnd As Variant
Dim rplc As Variant
fnd = "'"
rplc = ""
'Store a specfic sheet to a variable
Set sht = Sheets("Sheet1")
'Perform the Find/Replace All
sht.Cells.Replace what:=fnd, Replacement:=rplc, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
End Sub
Essentially, I am looking for a macro that runs over a fairly large range in a worksheet (~ 10,000 cells) and replace any leading apostrophes/high commas whilst minimizing runtime. I am not sure I can avoid addressing each cell individually but hoping there is another way.
Thank in advance