I am trying to remove the apostrophe that excel place automatically at the beginning of a string, I wrote the code here below to delete the apostrophe. The code detects the char (') but did not delete it. When you delete it and the string has more than 15 chars, Excel converts it to a scientific notation. The following data is an example of the data I have on the cell in Excel:
'2545879535879652'
'2545879535879652'
Thank.
Private Sub selectRange_Click()
Dim sht As Worksheet
Dim LastRow As Long
Dim rGn As Range
Dim arraySize() As String
Set ws = ThisWorkbook.Sheets("PruebaRossi")
ws.Activate
LastRow = ws.Range("E" & ws.Rows.Count).End(xlUp).row
Set rGn = ws.Range("E5:E" & LastRow)
rGn.Select
Dim cellValue As String
For Each cell In rGn
If Len(cell.value) > 0 Then ' Ensure the cell is not empty
MsgBox (Right (cell.value, 1))
If Right (cell.value, 1) = "'" Then
MsgBox (Right (cell.value, 1))
valueCell = Right (cell.value, Len(cell.value) - 1)
cell.value = valueCell
Else
MsgBox "No, it is not."
End If
End If
Next cell
End Sub
CSng(cell.Value)
followed bycell.NumberFormat = "0"
.