I have this range of data, which is a takeoff of engineered wood products. This is just a small excerpt of a spreadsheet that gets produced from an AutoCAD program I use. For clarify, I didn't show all of this, but normally there can be at least 2 or 3 other ranges of data inserted above, with each range separated by a row of blank cells. The number of Columns are fixed, but the start of the range can occur on different Row numbers. What I would like to do is create a macro that will Find and Replace All the three different values (“-“, “STD.” and “1/16””) in Column A (“MARK”) with a new abbreviated mark, based on the values of Column D (“DIMENSIONS”) and Column E (“GRADE”).
I would like the new abbreviated mark to follow this nomenclature:
For all occurrences of “-“ or “STD.”, the new abbreviated mark should read:
“Abbrev. Dimensions of the beam + Abbrev. Grade”
Dimensions (only includes the whole number from the width and height of the beam)
3 1/2” X 11 7/8” = “311”
Grade:
2.0E = “LVL”
1.55E = “LSL”
30F-E2 = “BB”
24F-V4 = “GLB”
Example for Cell “A4” = “311LVL”
For all occurrences of “1/16””, the new abbreviated mark should read:
“Abbrev. Dimensions + “HDR”
Example for Cell “A8” = “511HDR”
I first approached this by trying to use the SUBSTITUTE function because I knew I’d be able to utilize and manipulate the existing text to create the new abbreviated mark that I wanted.
So with SUBSTITUTE nested several times, I combined the cell values from Column D and Column E, and removed all spaces, fractions with the inches symbol (in this data set those are quotation marks), and replaced the grade with the abbreviated type. This formula produces the result I want.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D4&E4," ",""),"X",""),"""",""),"1.55E","LSL"),"2.0E","LVL"),"24F-V4","GLB"),"30F-E2","BB"),"1/4",""),"1/2",""),"3/4",""),"7/8","")
The issue with this formula, is that it needs to reference a cell address (in this example, "D4&E4"), which as I mentioned above, the start of the range can occur at different Row numbers because it's entirely dependent on how much material is listed in a given project.
I was unsuccessful in trying to record this macro, and I don’t know where to start to write this out in VBA. Is it possible to use Substitute and have it reference the address based on the ActiveCell address yielded by Find?
Using SUBSTITUTE nested seems really convoluted, but as you can imagine there are so many potential combinations of beam types and beam dimensions. This seems like the simplest way to account for all the potential combinations.
I'd really appreciate any suggestions or input on this. Thanks in advance.
I would like the new abbreviated mark to follow this nomenclature:
For all occurrences of “-“ or “STD.”, the new abbreviated mark should read:
“Abbrev. Dimensions of the beam + Abbrev. Grade”
Dimensions (only includes the whole number from the width and height of the beam)
3 1/2” X 11 7/8” = “311”
Grade:
2.0E = “LVL”
1.55E = “LSL”
30F-E2 = “BB”
24F-V4 = “GLB”
Example for Cell “A4” = “311LVL”
For all occurrences of “1/16””, the new abbreviated mark should read:
“Abbrev. Dimensions + “HDR”
Example for Cell “A8” = “511HDR”
I first approached this by trying to use the SUBSTITUTE function because I knew I’d be able to utilize and manipulate the existing text to create the new abbreviated mark that I wanted.
So with SUBSTITUTE nested several times, I combined the cell values from Column D and Column E, and removed all spaces, fractions with the inches symbol (in this data set those are quotation marks), and replaced the grade with the abbreviated type. This formula produces the result I want.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D4&E4," ",""),"X",""),"""",""),"1.55E","LSL"),"2.0E","LVL"),"24F-V4","GLB"),"30F-E2","BB"),"1/4",""),"1/2",""),"3/4",""),"7/8","")
The issue with this formula, is that it needs to reference a cell address (in this example, "D4&E4"), which as I mentioned above, the start of the range can occur at different Row numbers because it's entirely dependent on how much material is listed in a given project.
I was unsuccessful in trying to record this macro, and I don’t know where to start to write this out in VBA. Is it possible to use Substitute and have it reference the address based on the ActiveCell address yielded by Find?
Using SUBSTITUTE nested seems really convoluted, but as you can imagine there are so many potential combinations of beam types and beam dimensions. This seems like the simplest way to account for all the potential combinations.
I'd really appreciate any suggestions or input on this. Thanks in advance.