The issue is that you cannot run the function .Value = StripChar(.Value)
on a range at once (as you tried) but only on a single cell. Therfore you need to loop from row 2
to LastRow
and apply the function to each single cell.
Also note that row counting variables need to be of type Long
because Excel has more rows than Integer
can handle. Actually I recommend always to use Long
instead of Integer
as there is no benefit in using Integer
in VBA.
Also if you set your worksheet to a variable ws
you need to use this variable for all .Cells
and .Range
objects otherwise this is useless.
Option Explicit
Public Sub Alphabetremove()
Dim ws As Worksheet
Set ws = ActiveSheet 'better define a workseet by name unless you use the code for multiple worksheets:
'Set ws = ThisWorkbook.Worksheets("MySheet")
Dim LastRow As Long
LastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
Dim Cell As Range
For Each Cell In ws.Range("F2:F" & LastRow)
Cell.Value = StripChar(Cell.Value)
Next Cell
End Sub
Finally I highly recommend you to read How to avoid using Select in Excel VBA and apply this to all of your code.