find first 12 characters in cell using a macro

Juleew

New Member
Joined
Nov 24, 2009
Messages
45
I am trying to use the first 12 characters of a cell (before the first comma of the string) as a value in a macro. I just can't remember the formula for the macro to bascialy trim everything after the first comma, if there is a comma.
if my 5 values are (B1 - B5)
<TABLE style="WIDTH: 284pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=379 border=0><COLGROUP><COL style="WIDTH: 284pt; mso-width-source: userset; mso-width-alt: 13860" width=379><TBODY><TR style="HEIGHT: 15pt" height=20><TD class=xl118 style="BORDER-RIGHT: #c0c0c0; BORDER-TOP: #c0c0c0; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 284pt; BORDER-BOTTOM: #c0c0c0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" width=379 height=20>Column B
RD003431, xyw , xyw
</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl118 style="BORDER-RIGHT: #c0c0c0; BORDER-TOP: #c0c0c0; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: #c0c0c0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20> blank cell</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl118 style="BORDER-RIGHT: #c0c0c0; BORDER-TOP: #c0c0c0; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: #c0c0c0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20> blank cell</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl118 style="BORDER-RIGHT: #c0c0c0; BORDER-TOP: #c0c0c0; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: #c0c0c0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>Storeroom Location, Courier</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl118 style="BORDER-RIGHT: #c0c0c0; BORDER-TOP: #c0c0c0; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: #c0c0c0; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>RD003577 A05, xyz</TD></TR></TBODY></TABLE>

so for B1, x = RD003431 and trim everything after that first comma, I then use that value for other calculations in the macro. If the value is blank or does not have the RD in the first 2 chars I want to skip the cell. I just can't figure out how to get the value to x that I want to process furher in my macro...
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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