ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Delete 4 to 5 digits from left in a cell (https://www.excelbanter.com/excel-discussion-misc-queries/85696-re-delete-4-5-digits-left-cell.html)

Bob Phillips

Delete 4 to 5 digits from left in a cell
 

iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = 1 To iLastRow
With Cells(i,"A")
iPos = InStr(":",.Value)
if iPos 0 Then
.Value = Right(.Value, Len(.Value) - iPos)
End If
End With
Next i

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"saziz" wrote in
message ...

Hi,
I got a sheet where I need to delete number followed by ':'. All these
numbers are at the left in a cell like this--- 300: text.... few
hundred rows. Any help please?
Aziz


--
saziz
------------------------------------------------------------------------
saziz's Profile:

http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=536939




saziz

Delete 4 to 5 digits from left in a cell
 

Hi Bob,
I fix my problem, thank you. But wanted to try your code.
At this line: For i = 1 To Len(a) it gives me an error "Invalid outside
procedure"
I don't know what is.
Aziz


--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=536939


Bob Phillips

Delete 4 to 5 digits from left in a cell
 
You need to put it in a macro, for instance

Sub RemoveData()
iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = 1 To iLastRow
With Cells(i,"A")
iPos = InStr(":",.Value)
if iPos 0 Then
.Value = Right(.Value, Len(.Value) - iPos)
End If
End With
Next i
End Sub

then run RemoveData

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"saziz" wrote in
message ...

Hi Bob,
I fix my problem, thank you. But wanted to try your code.
At this line: For i = 1 To Len(a) it gives me an error "Invalid outside
procedure"
I don't know what is.
Aziz


--
saziz
------------------------------------------------------------------------
saziz's Profile:

http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=536939





All times are GMT +1. The time now is 11:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com