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.


BrandProduct NamePart
Number
NoteS120C0S0NG08

<colgroup><col><col><col></colgroup><tbody>
</tbody>

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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,202,909
Messages
6,052,495
Members
444,587
Latest member
ezza59

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