Find and rename the cell using vba

redvelvet

New Member
Joined
Jul 18, 2014
Messages
20
Hello Guys,
I'm wondering why i could not rename column C.


[TABLE="width: 237"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Brand[/TD]
[TD]Product Name[/TD]
[TD]Part
Number[/TD]
[/TR]
[TR]
[TD]Note[/TD]
[TD]S1[/TD]
[TD]20C0S0NG08[/TD]
[/TR]
</tbody>[/TABLE]

Here are the codes i used:
Cells.Replace What:="PartNumber", Replacement:="Product ID", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Please assist me. Thank you
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
There is no space in 'PartNumber' of What:=. At least as rendered in your post, 'Part Number' has either a space, a linefeed, or both.
 
Upvote 0
Hi redvelvet,

Well, I hope I am not guessing too wildly, as I am going by what your post's rendering makes it appear to be. Let's do a simple test:

Select the cell that has "Part Number" in it. In a Standard Module, run:

Rich (BB code):
Option Explicit
  
Sub GetChrVals()
Dim s As String, sText As String
Dim n As Long
  
  For n = 1 To Len(ActiveCell.Value)
    s = s & Asc(Mid$(ActiveCell.Value, n, 1)) & ", "
  Next
  
  Debug.Print s
  
End Sub

See what is in the Immediete Window. If there are no extra characters, and a linefeed is included, I get: 80, 97, 114, 116, 10, 78, 117, 109, 98, 101, 114,

I have not tried .Find with this yet, but I would assume we'd need to include the linefeed.


Mark
 
Upvote 0
Not certain, but pretty sure it is just a linefeed so try this in you Replace line
Code:
What:="Part" & Chr(10) & "Number"
 
Upvote 0

Forum statistics

Threads
1,222,384
Messages
6,165,669
Members
451,983
Latest member
Raph24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top