smide
Board Regular
- Joined
- Dec 20, 2015
- Messages
- 164
- Office Version
- 2016
- Platform
- Windows
Hello.
I need some assistance with an excel spreadsheet which contains very raw output report in row 1 (Sheet2) columns (A-NO).
I'm not very proficient with excel-vba but I'm open to suggestions and willing to learn to get this to work properly.
As I already stated in row1 in Sheet2 I have a raw report output which contains certain Product prices.
Each product is presented with four characteristics: unique Product's id and three prices (shop, factory and market).
The problem is that I need to find cells that contain this data about product's id and prices, then to extract only numbers from those cells without unnecessary characters.
There are certain rules in raw output report that deserves attention:
1a) The cells which contain product's prices (all cells are in row 1, Sheet2 as I said) always follow the next pattern:
Example.
Sheet2
cell (1,D) productne:{"shop":15.80
cell (1,E) fact:10.40
cell (1,F) mark:14.20}
* so, cells with this characteristics/special characters/brackets are always consecutive cells in row 1 (Sheet2) - I need to extract only number from them (15.80 10.40 14.20)
1b) Sometimes "dummy" cells appears with contents: storTotal:{"shop":{"totals":75 or cells with contents: shop:19.30 are also "dummy" cells - I do not need number from this type of cells, skip them (!!)
Summary: when it comes to product's prices extract ONLY numbers from cells with productne:{"shop": content and only they can be considered as the first relevant and then I need (ALWAYS) also number(s) from following two cells (fact: and mark
2) Product's id
- There are four type of cells in total which contain product's id characteristics (again of course all cells are somewhere in row 1, Sheet2):
Product id cell types:
2a) events:[{"id":45 - I need only number 45 from this type of cell
2b) {"id":626702572 - I need only number 626702572
but there are also "dummy" cells with similar "id" characteristics:
2c) account:[{"id":2370
or
2d) annual:[{"id":3460
I do not need id from these cells (!!) (from 2c) and/or 2d) ) - skip them (!)
3) "Between" rule
Obviously trio (shop-fact-mark eg. those three cells) are always somewhere between two cells with 2a) or 2b) contents (between two product id's).
Valid Product id is always the first left cell, left to the shop-fact-mark trio.
Important: Sometimes between two cells with id characteristics (two id's) there are no this required cell with productne:{"shop": content.
In that case the whole row after id stays empty (see example below).
[TABLE="class: grid, width: 250, align: center"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[TD]P[/TD]
[TD]Q[/TD]
[TD]R[/TD]
[TD]S[/TD]
[TD]T[/TD]
[TD]U[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]events:[{"id":[/TD]
[TD]status:"I"[/TD]
[TD]events:[{"id":7650[/TD]
[TD]starts:[/TD]
[TD]maxTotal:50[/TD]
[TD]{"id":976[/TD]
[TD]shop:19.30[/TD]
[TD]productne:{"shop":15.80[/TD]
[TD]fact:10.40
[/TD]
[TD]mark:14.20}
[/TD]
[TD]maxSpread:5000.0[/TD]
[TD]shop:35.23[/TD]
[TD]fact:12[/TD]
[TD]{"id":3333[/TD]
[TD]account:[{"id":2370[/TD]
[TD]cutoff:[/TD]
[TD]{"id":45700
[/TD]
[TD]productne:{"shop":77.88
[/TD]
[TD]fact:72.11
[/TD]
[TD]mark:75.80}
[/TD]
[TD]....[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
* I bolded only valid cells, please notice how I skipped "dummy" cells/data in G1,L1,M1 and O1.
Also, there are no required productne:{"shop": cell after 7650 and 3333 Product id's so the rest of that row(s) is empty.
I want to run my code from Sheet1 and results (according to above example) should be in Sheet1 cells J3:M3.
[TABLE="class: grid, width: 250, align: center"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]J[/TD]
[TD="align: center"]K[/TD]
[TD="align: center"]L[/TD]
[TD="align: center"]M[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]id[/TD]
[TD="align: center"]shop[/TD]
[TD="align: center"]fact[/TD]
[TD="align: center"]mark[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]7650[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]976[/TD]
[TD="align: center"]15.80[/TD]
[TD="align: center"]10.40[/TD]
[TD="align: center"]14.20[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]3333[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]45700[/TD]
[TD="align: center"]77.88[/TD]
[TD="align: center"]72.11[/TD]
[TD="align: center"]75.80[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]
(apologize for the long post)
I need some assistance with an excel spreadsheet which contains very raw output report in row 1 (Sheet2) columns (A-NO).
I'm not very proficient with excel-vba but I'm open to suggestions and willing to learn to get this to work properly.
As I already stated in row1 in Sheet2 I have a raw report output which contains certain Product prices.
Each product is presented with four characteristics: unique Product's id and three prices (shop, factory and market).
The problem is that I need to find cells that contain this data about product's id and prices, then to extract only numbers from those cells without unnecessary characters.
There are certain rules in raw output report that deserves attention:
1a) The cells which contain product's prices (all cells are in row 1, Sheet2 as I said) always follow the next pattern:
Example.
Sheet2
cell (1,D) productne:{"shop":15.80
cell (1,E) fact:10.40
cell (1,F) mark:14.20}
* so, cells with this characteristics/special characters/brackets are always consecutive cells in row 1 (Sheet2) - I need to extract only number from them (15.80 10.40 14.20)
1b) Sometimes "dummy" cells appears with contents: storTotal:{"shop":{"totals":75 or cells with contents: shop:19.30 are also "dummy" cells - I do not need number from this type of cells, skip them (!!)
Summary: when it comes to product's prices extract ONLY numbers from cells with productne:{"shop": content and only they can be considered as the first relevant and then I need (ALWAYS) also number(s) from following two cells (fact: and mark

2) Product's id
- There are four type of cells in total which contain product's id characteristics (again of course all cells are somewhere in row 1, Sheet2):
Product id cell types:
2a) events:[{"id":45 - I need only number 45 from this type of cell
2b) {"id":626702572 - I need only number 626702572
but there are also "dummy" cells with similar "id" characteristics:
2c) account:[{"id":2370
or
2d) annual:[{"id":3460
I do not need id from these cells (!!) (from 2c) and/or 2d) ) - skip them (!)
3) "Between" rule
Obviously trio (shop-fact-mark eg. those three cells) are always somewhere between two cells with 2a) or 2b) contents (between two product id's).
Valid Product id is always the first left cell, left to the shop-fact-mark trio.
Important: Sometimes between two cells with id characteristics (two id's) there are no this required cell with productne:{"shop": content.
In that case the whole row after id stays empty (see example below).
[TABLE="class: grid, width: 250, align: center"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[TD]J[/TD]
[TD]K[/TD]
[TD]L[/TD]
[TD]M[/TD]
[TD]N[/TD]
[TD]O[/TD]
[TD]P[/TD]
[TD]Q[/TD]
[TD]R[/TD]
[TD]S[/TD]
[TD]T[/TD]
[TD]U[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]events:[{"id":[/TD]
[TD]status:"I"[/TD]
[TD]events:[{"id":7650[/TD]
[TD]starts:[/TD]
[TD]maxTotal:50[/TD]
[TD]{"id":976[/TD]
[TD]shop:19.30[/TD]
[TD]productne:{"shop":15.80[/TD]
[TD]fact:10.40
[/TD]
[TD]mark:14.20}
[/TD]
[TD]maxSpread:5000.0[/TD]
[TD]shop:35.23[/TD]
[TD]fact:12[/TD]
[TD]{"id":3333[/TD]
[TD]account:[{"id":2370[/TD]
[TD]cutoff:[/TD]
[TD]{"id":45700
[/TD]
[TD]productne:{"shop":77.88
[/TD]
[TD]fact:72.11
[/TD]
[TD]mark:75.80}
[/TD]
[TD]....[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
* I bolded only valid cells, please notice how I skipped "dummy" cells/data in G1,L1,M1 and O1.
Also, there are no required productne:{"shop": cell after 7650 and 3333 Product id's so the rest of that row(s) is empty.
I want to run my code from Sheet1 and results (according to above example) should be in Sheet1 cells J3:M3.
[TABLE="class: grid, width: 250, align: center"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]J[/TD]
[TD="align: center"]K[/TD]
[TD="align: center"]L[/TD]
[TD="align: center"]M[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]id[/TD]
[TD="align: center"]shop[/TD]
[TD="align: center"]fact[/TD]
[TD="align: center"]mark[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]7650[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]976[/TD]
[TD="align: center"]15.80[/TD]
[TD="align: center"]10.40[/TD]
[TD="align: center"]14.20[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]3333[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]45700[/TD]
[TD="align: center"]77.88[/TD]
[TD="align: center"]72.11[/TD]
[TD="align: center"]75.80[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]
(apologize for the long post)
Last edited: