Macro to pull data from A2:K2

B.Kellough

Board Regular
Joined
Aug 1, 2009
Messages
180
I'm needing a macro that will pull data from A2:K2 and remove everything from the data except for the numbers only. for example A2 has "|16.51%" in the cell, the macro would remove "|" and "%" and leave the 16.51 and remove any spaces before the 16.51.

Thanks in advance for any help with this.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
You didn't answer my question about what is in A2:F2 ;)

If you are getting that after running the macro, it would indicate that the values in A2:F2 are not numbers.

Do they look like numbers?

In a blank cell put
=ISNUMBER(A2)
and drag that right to fill 6 horizontal cells. The results I presume are FALSE

In another blank cell
=LEN(A2)
and drag right. Do those results seem unusual?
 
Upvote 0
My guess is that the 'space' that we removed was not actually a space so it is still in the cell.

Put this in a vacant cell. I put this in K11, if you use a different cell change the K11s in the formula to the cell where you put the formula. Make sure you keep the $ signs where they are.

=CODE(MID($A$2,ROWS(K$11:K11),1))

Now drag the formula down to fill 5 cells.

Tell us what those 5 values are AND what you are seeing in cell A2.
 
Upvote 0
A2 has "8.34" in it. After pasting the formula in cell "P11" and dragging down 5 here is what I get 160, 56, 46, 51, 52.

I changed the K11 in the formula to P11.
 
Upvote 0
OK, in the code edit the final 'Replace' line like this
Rich (BB code):
.Replace What:=Chr(160), Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
Lawrenceiow

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