Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
need help replacing string with "."
i used a macro to replace the "." but can someone tell me how to replace
"."and the text following the period. i mean when ever it hits a period it should delete everything thats after the "." Public Sub Tester() Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim rCell As Range Set WB = Workbooks("MasterList.xls") Set SH = WB.Sheets("VT Masterlist") ' Set rng = SH.Range("A:A") For Each rCell In rng.Cells With rCell If Not IsEmpty(.Value) Then .Replace What:=".", Replacement:="" End If End With Next rCell End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
need help replacing string with "."
For Each rcell In rng.Cells
With rcell ipos = InStr(rcell.Value, ".") If ipos 0 Then rcell.Value = Left(rcell.Value, ipos - 1) End If End With Next rcell -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Arain" wrote in message ... i used a macro to replace the "." but can someone tell me how to replace "."and the text following the period. i mean when ever it hits a period it should delete everything thats after the "." Public Sub Tester() Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim rCell As Range Set WB = Workbooks("MasterList.xls") Set SH = WB.Sheets("VT Masterlist") ' Set rng = SH.Range("A:A") For Each rCell In rng.Cells With rCell If Not IsEmpty(.Value) Then .Replace What:=".", Replacement:="" End If End With Next rCell End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
need help replacing string with "."
I am going with the bulky approach. God, your code is so compact.
I will do: Dim temp temp = Slip(ActiveCell.FormulaC1R1, ".") ActiveCell.FormulaC1R1 = temp(0) This simply set the formula to anything that's before the "." "Arain" wrote: i used a macro to replace the "." but can someone tell me how to replace "."and the text following the period. i mean when ever it hits a period it should delete everything thats after the "." Public Sub Tester() Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim rCell As Range Set WB = Workbooks("MasterList.xls") Set SH = WB.Sheets("VT Masterlist") ' Set rng = SH.Range("A:A") For Each rCell In rng.Cells With rCell If Not IsEmpty(.Value) Then .Replace What:=".", Replacement:="" End If End With Next rCell End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
need help replacing string with "."
Thank you guys great help
"jchen" wrote: I am going with the bulky approach. God, your code is so compact. I will do: Dim temp temp = Slip(ActiveCell.FormulaC1R1, ".") ActiveCell.FormulaC1R1 = temp(0) This simply set the formula to anything that's before the "." "Arain" wrote: i used a macro to replace the "." but can someone tell me how to replace "."and the text following the period. i mean when ever it hits a period it should delete everything thats after the "." Public Sub Tester() Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim rCell As Range Set WB = Workbooks("MasterList.xls") Set SH = WB.Sheets("VT Masterlist") ' Set rng = SH.Range("A:A") For Each rCell In rng.Cells With rCell If Not IsEmpty(.Value) Then .Replace What:=".", Replacement:="" End If End With Next rCell End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
need help replacing string with "."
Another way...
If you select column A and do edit|replace what: *. (asterisk, dot) with: (leave blank) replace all You can get all of the cells in one fell swoop. In code: sh.Range("A:A").Replace What:=".*", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False Arain wrote: i used a macro to replace the "." but can someone tell me how to replace "."and the text following the period. i mean when ever it hits a period it should delete everything thats after the "." Public Sub Tester() Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim rCell As Range Set WB = Workbooks("MasterList.xls") Set SH = WB.Sheets("VT Masterlist") ' Set rng = SH.Range("A:A") For Each rCell In rng.Cells With rCell If Not IsEmpty(.Value) Then .Replace What:=".", Replacement:="" End If End With Next rCell End Sub -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
need help replacing string with "."
That first routine removed the dot and everything following it. If you wanted
to keep the period: SH.Range("a:a").Replace What:=".*", Replacement:=".", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False Arain wrote: i used a macro to replace the "." but can someone tell me how to replace "."and the text following the period. i mean when ever it hits a period it should delete everything thats after the "." Public Sub Tester() Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim rCell As Range Set WB = Workbooks("MasterList.xls") Set SH = WB.Sheets("VT Masterlist") ' Set rng = SH.Range("A:A") For Each rCell In rng.Cells With rCell If Not IsEmpty(.Value) Then .Replace What:=".", Replacement:="" End If End With Next rCell End Sub -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
=SUBSTITUTE(C4,"~?#","") will this work to remove multiple string | Excel Worksheet Functions | |||
Converting "uppercase" string data to "lower case" in CSV file | Excel Discussion (Misc queries) | |||
text string: "91E10" in csv file auto converts to: "9.10E+11" | Excel Discussion (Misc queries) | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Making "examp le" become "examp_le" in a string | Excel Programming |