I need to extract a number from a string which is written in a cell.
For example:- A1 contains the text: 74 Upper specification limit of product
- A2 contains the text: 70 Lower specification limit of product
- A3 contains the text: 72 Nominal value required
- A4 contains the text: 5 % defects accepted in product
- A5 contains the text: 8 number of items per sample required
I need to use the numbers (74, 70, 72, 5, 8) as variables in calculations later on in my code.
For example:- USL = 74
- LSL = 70
- Nom = 72
- Def = 5
- n = 8
How do I go about stepping through each cell and extraction the numbers and saving them as variables? I would probably use the space after each number as the break point but I am new fairly inexperianced with VBA and I'm not sure how to do this.
Solved with:
Dim test As Long
Dim Position1 As Long
Position1 = InStr(1, Sheets("Data").Range("A1"), " ")
test = Mid(Sheets("Data").Range("A1"), 1, Position1 - 1)
Sheets("Data").Range("J1") = test
Bookmarks