3

In Excel, this is an example of the cell values. "▲99315","▲65". I'm trying to use VBA to remove the arrows which are always up or down, for gain or loss.

I can't seem to make this work using VBA. When I open this workbook it is auto updated. I would like to run a VBA to "Find and Replace" the arrows. When I try to paste the arrow characters in "find" it shows as a "?".

0m3r
  • 12,286
  • 15
  • 35
  • 71
sms
  • 33
  • 4
  • 2
    if they are in every cell, use text-to-columns to split the column into two and then delete the first column – jsotola Sep 25 '17 at 18:41
  • 1
    Also can you include a screenshot, so we know exactly what arrows are being used? You may need to use the unicode character to remove them (an [example is here](https://stackoverflow.com/q/37024107/4650297)) – BruceWayne Sep 25 '17 at 18:42
  • 2
    you can also use a formula, say the value is in A1: =MID(A1,2,LEN(A1)) assumes the arrow is always the first char. – Sorceri Sep 25 '17 at 18:47

3 Answers3

2

If all of those numbers compulsorily contain the first character as one of up and down arrows, you may give this a try....

The following code assumes that your numbers are in column A and start from Row2. If not, change it as per your requirement.

Sub ReplaceArrows()
    Dim lr As Long
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    Range("A2:A" & lr).Value = Evaluate("=IF(A2:A" & lr & "="""","""",RIGHT(A2:A" & lr & ",LEN(A2:A" & lr & ")-1)+0)")
End Sub
Subodh Tiwari sktneer
  • 9,906
  • 2
  • 18
  • 22
1

To use VBA Find, you need to determine the code for the character you want to replace. Assuming the arrows you are using are the same as you pasted into your question, the following code will work:

with myRange
    .Replace what:=ChrW(&H25B2), replacement:=""  'Up Arrow
    .Replace what:=ChrW(&H25BC), replacement:=""  'Down Arrow
end with

Note the use of ChrW for the double byte character, and the Hex Code representing the up and down arrows.

Ron Rosenfeld
  • 53,870
  • 7
  • 28
  • 60
0

if these are conditional formatting icons you need to use the rng.FormatConditions.Delete method.

GSD
  • 1,252
  • 1
  • 10
  • 12