Need VBA to locate two specific characters the first time they appear together in the data and enter all data that precedes those two specified charac

skyport

Active Member
Joined
Aug 3, 2014
Messages
374
If I use the paragraph below as an example, the two specific characters to look for would be the first time there is a period (.) followed by a space. In the example below, those characters together occur once around the middle of the paragraph and at the end as well.

Example Paragraph:
Need VBA to locate two specific characters the first time they appear together in different paragraphs in column A. It would then enter all data that comes before those two specified characters to another column-B. Thanks.

The idea behind what is needed for the code to do the job would be to find that first occurrence of the two characters within that paragraph in Column A and then enter all the data that comes before those two characters in that paragraph and enter the result in the next column -B in a cell by itself.

Using the above example paragraph, the result in a cell by itself in column B would be as follows:

Need VBA to locate two specific characters the first time they appear together in different paragraphs in column A.

The result is the data in the paragraph from column A only up to the first occurrence of those two characters together is entered in a cell by itself in column B. The code should then repeat that process for each subsequent paragraph in column A using a separate cell in column B for each result. Note: Every paragraph would be separated from the paragraph above and below with a blank line.
 
@Rick: I try to figure out how your code works but I do not understand the @A1:A# syntax. Is this array processing? Can you point me to articles on that?
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Rick, It worked perfectly and got the first line as well to resolve that issue. I want to thank both of you for your kind help.
 
Upvote 0
@Rick: I try to figure out how your code works but I do not understand the @A1:A# syntax. Is this array processing? Can you point me to articles on that?
The @ symbol is a stand-in character for the sheet name reference and the # symbol is a stand-in character for the last row number (which was calculated earlier in the macro... any two characters would do so long as they do not appear in the rest of the text naturally. See the two Replace function calls... they do the replacements for those characters so that the final argument to the Evaluate function is correct. I do it using the replacement because the makes the text easier to construct than would be the case if I concatenated the sheet name reference variable and last row variable directly in the text all three times each are needed there.
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,126
Members
452,381
Latest member
Nova88

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