ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro (https://www.excelbanter.com/excel-discussion-misc-queries/176428-macro.html)

shifty

Macro
 
Please help

is there a way to run a command of macro that will delete the 1st 17
characters of a cell that is selected?

Thanks

Mike H

Macro
 
Maybe

Sub marine()
If Len(ActiveCell.Value) 16 Then
ActiveCell.Value = Mid(ActiveCell.Value, 18, Len(ActiveCell.Value) - 17)
End If
End Sub

Mike

"shifty" wrote:

Please help

is there a way to run a command of macro that will delete the 1st 17
characters of a cell that is selected?

Thanks


shifty

Macro
 
Thanks
Can you apply this to a range of cells when selecte in a column?




"Mike H" wrote:

Maybe

Sub marine()
If Len(ActiveCell.Value) 16 Then
ActiveCell.Value = Mid(ActiveCell.Value, 18, Len(ActiveCell.Value) - 17)
End If
End Sub

Mike

"shifty" wrote:

Please help

is there a way to run a command of macro that will delete the 1st 17
characters of a cell that is selected?

Thanks


Dave Peterson

Macro
 
If you have a column of this stuff, you could record a macro when you:

Select the range
Data|Text to columns
Fixed width
remove any lines that excel guessed, but add a line between character 17 and 18.

Choose to skip the first field

Choose general or text or whatever you want for the second field.

shifty wrote:

Please help

is there a way to run a command of macro that will delete the 1st 17
characters of a cell that is selected?

Thanks


--

Dave Peterson

Mike H

Macro
 
try this

Sub marine()
For Each c In Selection
If Len(c.Value) 16 Then
c.Value = Mid(c.Value, 18, Len(c.Value) - 17)
End If
Next
End Sub

Mike

"shifty" wrote:

Thanks
Can you apply this to a range of cells when selecte in a column?




"Mike H" wrote:

Maybe

Sub marine()
If Len(ActiveCell.Value) 16 Then
ActiveCell.Value = Mid(ActiveCell.Value, 18, Len(ActiveCell.Value) - 17)
End If
End Sub

Mike

"shifty" wrote:

Please help

is there a way to run a command of macro that will delete the 1st 17
characters of a cell that is selected?

Thanks



All times are GMT +1. The time now is 12:53 PM.

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