Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
=SUBSTITUTE(C4,"~?#","") will this work to remove multiple string Raja Mahendiran S Excel Worksheet Functions 6 May 12th 10 09:10 PM
Converting "uppercase" string data to "lower case" in CSV file [email protected] Excel Discussion (Misc queries) 2 August 12th 08 08:36 PM
text string: "91E10" in csv file auto converts to: "9.10E+11" [email protected] Excel Discussion (Misc queries) 2 August 12th 08 03:13 PM
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
Making "examp le" become "examp_le" in a string Sworkhard Excel Programming 3 October 29th 04 09:31 PM


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

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"