Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Change the second to last from "0" to "-"

Hello from Steved

Column B:B
numerals 6 to 8

Objective

Change the second to last from "0" to "-" please

I Thankyou.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Change the second to last from "0" to "-"

Sub replacezero()

MyStr = "abc000"
LastZero = InStrRev(MyStr, "0")
If LastZero 0 Then
If LastZero 1 Then
NextZero = InStrRev(MyStr, "0", LastZero - 1)
End If
If NextZero 0 Then
MyStr = Left(MyStr, NextZero - 1) & "-" & _
Mid(MyStr, NextZero + 1)
End If
End If

End Sub
"Steved" wrote:

Hello from Steved

Column B:B
numerals 6 to 8

Objective

Change the second to last from "0" to "-" please

I Thankyou.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Change the second to last from "0" to "-"

Hello Joel


Joel I'm not able to get your macro to work.

Please what I'm I doing wrong

Steved

"joel" wrote:

Sub replacezero()

MyStr = "abc000"
LastZero = InStrRev(MyStr, "0")
If LastZero 0 Then
If LastZero 1 Then
NextZero = InStrRev(MyStr, "0", LastZero - 1)
End If
If NextZero 0 Then
MyStr = Left(MyStr, NextZero - 1) & "-" & _
Mid(MyStr, NextZero + 1)
End If
End If

End Sub
"Steved" wrote:

Hello from Steved

Column B:B
numerals 6 to 8

Objective

Change the second to last from "0" to "-" please

I Thankyou.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Change the second to last from "0" to "-"

Give this macro a try...

Sub ReplaceNextToLastZeroWithDash()
Dim C As Range, T As String
For Each C In Intersect(Columns("B"), ActiveSheet.UsedRange)
T = C.Text
If Len(T) 1 Then
If Mid(T, Len(T) - 1, 1) = "0" Then
Mid(T, Len(T) - 1, 1) = "-"
C.Value = T
End If
End If
Next
End Sub

--
Rick (MVP - Excel)


"Steved" wrote in message
...
Hello from Steved

Column B:B
numerals 6 to 8

Objective

Change the second to last from "0" to "-" please

I Thankyou.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Change the second to last from "0" to "-"

Hello Rick

Excellent thankyou

Steved

"Rick Rothstein" wrote:

Give this macro a try...

Sub ReplaceNextToLastZeroWithDash()
Dim C As Range, T As String
For Each C In Intersect(Columns("B"), ActiveSheet.UsedRange)
T = C.Text
If Len(T) 1 Then
If Mid(T, Len(T) - 1, 1) = "0" Then
Mid(T, Len(T) - 1, 1) = "-"
C.Value = T
End If
End If
Next
End Sub

--
Rick (MVP - Excel)


"Steved" wrote in message
...
Hello from Steved

Column B:B
numerals 6 to 8

Objective

Change the second to last from "0" to "-" please

I Thankyou.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
=IF(D13="PAID","YES","NO") Can I change fonts colour Kev Excel Discussion (Misc queries) 3 February 17th 06 04:27 AM


All times are GMT +1. The time now is 06:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"