Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default renaming text in cell


Hello hope somebody can help me out with this, driving me nuts. I´m
trying to rename specific cells (which start with the word "Cd" into
CDC Philly, but something is wrong here, pretty sure it´s the
identifier.

Sub TextChange()

Dim rng As Characters
Dim i As Double, counter As Double
Sheets("Retail Raw Data").Select
Set rng = Range("o2:o65000")
i = 1
Set rng = .Search("cd ", LookIn:=x1values)
If Not rng Is Nothing Then
Retail = rng.gildi
Do
rng.Value = "Empty"
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing And rng.gildi Is Not "Empty"
End If
End With
For counter = 1 To rng.Rows.Count
If rng.Cells(i) = "Empty" Then
rng.Cells(i).FormulaR1C1 = "CDC Philly"
Else
i = i + 1
End If
Next
End Sub


--
jhkr
------------------------------------------------------------------------
jhkr's Profile: http://www.excelforum.com/member.php...o&userid=24665
View this thread: http://www.excelforum.com/showthread...hreadid=382413

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default renaming text in cell

How about just selecting your range and doing:

Edit|replace
what: CD_ (_ is the spacebar)
with: CDC Philly
replace all.

If you want to replace the contents of the whole cell when it starts with CD_:

Edit|replace
what: CD_* (_ is the spacebar)
with: CDC Philly
replace all.

If you need a macro, record one when you do it manually.

You'll see some significant differences.

search will be replaced with Find and x(one)values will become x(ell)values.




jhkr wrote:

Hello hope somebody can help me out with this, driving me nuts. I´m
trying to rename specific cells (which start with the word "Cd" into
CDC Philly, but something is wrong here, pretty sure it´s the
identifier.

Sub TextChange()

Dim rng As Characters
Dim i As Double, counter As Double
Sheets("Retail Raw Data").Select
Set rng = Range("o2:o65000")
i = 1
Set rng = .Search("cd ", LookIn:=x1values)
If Not rng Is Nothing Then
Retail = rng.gildi
Do
rng.Value = "Empty"
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing And rng.gildi Is Not "Empty"
End If
End With
For counter = 1 To rng.Rows.Count
If rng.Cells(i) = "Empty" Then
rng.Cells(i).FormulaR1C1 = "CDC Philly"
Else
i = i + 1
End If
Next
End Sub

--
jhkr
------------------------------------------------------------------------
jhkr's Profile: http://www.excelforum.com/member.php...o&userid=24665
View this thread: http://www.excelforum.com/showthread...hreadid=382413


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default renaming text in cell

I see a few things that are problematic, plus a one thing I am just confused
about:
1) It should be Dim rng as Range
2) When you have rng.Cells(i).FormulaR1C1 = "CDC Philly" it is setting the
contents of the cell equal to "CDC Philly," not the name. To set the name
use rng.Cells(i).Name = "CDC Philly"
3) I have no clue what a rng.gildi is - I know of no Excel object with a
gildi property.

"jhkr" wrote:


Hello hope somebody can help me out with this, driving me nuts. I´m
trying to rename specific cells (which start with the word "Cd" into
CDC Philly, but something is wrong here, pretty sure it´s the
identifier.

Sub TextChange()

Dim rng As Characters
Dim i As Double, counter As Double
Sheets("Retail Raw Data").Select
Set rng = Range("o2:o65000")
i = 1
Set rng = .Search("cd ", LookIn:=x1values)
If Not rng Is Nothing Then
Retail = rng.gildi
Do
rng.Value = "Empty"
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing And rng.gildi Is Not "Empty"
End If
End With
For counter = 1 To rng.Rows.Count
If rng.Cells(i) = "Empty" Then
rng.Cells(i).FormulaR1C1 = "CDC Philly"
Else
i = i + 1
End If
Next
End Sub


--
jhkr
------------------------------------------------------------------------
jhkr's Profile: http://www.excelforum.com/member.php...o&userid=24665
View this thread: http://www.excelforum.com/showthread...hreadid=382413


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
Renaming tabs from particular cell contents scotty Excel Worksheet Functions 5 December 11th 07 05:44 PM
vb code for renaming a work sheet with a cell reference John Britto Excel Discussion (Misc queries) 3 September 17th 06 07:12 PM
Maintain cell links when renaming directory containing multiple f Excel52 Excel Worksheet Functions 0 April 28th 05 10:54 PM
Renaming a cell name Gary Paris[_3_] Excel Programming 1 February 8th 05 02:33 AM
Renaming Text Boxes and Buttons Don Wiss Excel Programming 4 December 26th 04 04:40 AM


All times are GMT +1. The time now is 08:36 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"