Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
=IF(D13="PAID","YES","NO") Can I change fonts colour | Excel Discussion (Misc queries) |