VBA solution to finding a string in a cell that is N chrs in length

Don Iliffe

New Member
Joined
Dec 18, 2008
Messages
15
I am trying to find a VBA solution to finding a string in a range of cells that is of a specified chrs length.

The purpose is to find, and then copy this string, and all other instances, to another worksheet. The copying part is not a problem, but I cannot come up with a solution that finds a string in the cells that is n chrs in length. (The actual length is nine(9) chrs)

Does anyone have any ideas on this.
 
Steve the Fish


OK! Found out the issue, it was calling the wrong macro.
Now when I try to call your UDF, sing '=extract_chars(a1)'. I am getting #NAME error

I have put the =extrac_char(a1) in cell B1 as the desired destination cell.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
that was my mong typing here, there is a big delay between keyboard and what is appearing on the screen and it sometime misses chars

Where do I put the 9?

Replacing Number of Characters with 9 does not work
 
Upvote 0
That was what I was using, but getting #NAME

Have now inserted a new module and put code there instead of the sheet code and it is working fine now. Tested using short cell data (no 9 char strings) and get a negative as well so all is good.

its taken me 10 mins to get this typed.

Many thanks for that.
 
Upvote 0
Yes that needs to go in a standard module. It should work. It does for me on your sample.
 
Upvote 0
tyija1995, thanks for your post as well, I am going try this as I can definitely use it. It does not help with my current issue. but I can think a multiple of uses for it. So thanks
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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