check only the first part of the cell content using macro

sisi001

New Member
Joined
Jun 24, 2011
Messages
10
Hi all,
I always received a great help from this website. Please help me with this one too.

Is there a command in macro that checks only the first part of the content of the cell. Like for example I need to replace any(provided there are certain rules but not important right now) cells that contains Name_new1 with a name(lets say John) that I copied from somewhere.

I am using a Do..while loop like shown below: But the * does not seem to work in this case.

Do

b = ActiveCell.Offset(1, 0).Value
ActiveCell.Offset(1, 0).Select

Loop While b <> "NAME_new*"
ActiveCell.Value = a ' where a is something i copied from another wb

Please help!!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Maybe something like
Code:
Do
              
      b = ActiveCell.Offset(1, 0).Value
      ActiveCell.Offset(1, 0).Select
                        
Loop While Not b Like "NAME_new*"
 ActiveCell.Value = a  ' where a is something i copied from another wb
 
Upvote 0
thanks for your quick reply. But I think i failed to explain my problem properly.

The cells now contain "Name_new1", "Name_new2", "Name_new3" and so on. So I need to replace these cells with "a" as soon as I see
"Name _new" numbers at the end should not matter.

Thank You
 
Upvote 0
My code is really long. let me just explain once again.

I have a spreadsheet with one of the column as follows:

Jenny
Tina
Name_new1
Marsha
Name_new2

Name_new1, Name_new2 needs to be updated with new names from a different workbook.

So I do my code to copy this new name from workbook1 and I go through the columns with names in workbook2 and whenever I see a cell that says Name_new1, I paste the new name to this cell, and I keep doing this until I finish the column.

What I wanted to know is if there is a command where it only checks Name, and as soon as it sees Name it starts pasting my stuffs.
 
Upvote 0
Sorry, I don't understand what you are trying to do. To perform a task on each cell that starts with "Name_new"


Code:
Dim c as Range
For each c in Range("A:A")
If c Like "New_name*" Then c = "enter desired result here"

Update range("A:A") to actual range
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,553
Members
452,928
Latest member
101blockchains

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