View Single Post
  #11   Report Post  
aswasis aswasis is offline
Junior Member
 
Location: Virginia, USA
Posts: 7
Default

[quote='GS[_2_];1611181']For completeness...

Public Function GetSize#(RangeRef As Range, Optional IsCubic&)
Dim vSizes
'Force lowercase and filter numbers and letter "x" only
'Allows use of alpha prefix for product IDs
vSizes = Split(FilterString(LCase$(RangeRef.Value), "x", False), "x")
GetSize = vSizes(UBound(vSizes) - 2) * vSizes(UBound(vSizes) - 1)
If IsCubic Then GetSize = GetSize * vSizes(UBound(vSizes))
End Function

...which can be used as follows...

A1: 8x8x7

Formula to return area:
B1: =getsize(A1)
Returns: 64

Formula to return volume:
C1: =getsize(A1,1)
Returns: 448

...and will allow use of alpha prefixes...

Part/Model #
AF-8x8x7 OR AF8X8X7 OR DX8X8X7 OR DX-8x8x7 etc.

Function FilterString$(ByVal TextIn As String, _
Optional IncludeChars As String, _
Optional IncludeLetters As Boolean = True, _
Optional IncludeNumbers As Boolean = True)
' Filters out all unwanted characters in a string.
' Arguments: TextIn The string being filtered.
' IncludeChars [Optional] Keeps any characters.
' IncludeLetters [Optional] Keeps any letters.
' IncludeNumbers [Optional] Keeps any numbers.
'
' Returns: String containing only the wanted characters.

'The basic characters to always keep
Const sLetters As String = "abcdefghijklmnopqrstuvwxyz"
Const sNumbers As String = "0123456789"

Dim i As Long, CharsToKeep As String

CharsToKeep = IncludeChars
If IncludeLetters Then _
CharsToKeep = CharsToKeep & sLetters & UCase(sLetters)
If IncludeNumbers Then CharsToKeep = CharsToKeep & sNumbers
'From a Balena sample
For i = 1 To Len(TextIn)
If InStr(CharsToKeep, Mid$(TextIn, i, 1)) Then _
FilterString = FilterString & Mid$(TextIn, i, 1)
Next
End Function 'FilterString()

--
Garry


Gary and others who tried to help me I appreciate it but way over my head. You guys have a gift!
Tried copying and pasting and no success what your saying.
Can someone interpret what I'm asking? My fault for not explaining myself better!! Apologize to all
1 I A I B I C I D I
2 I Size: I 8x8 I Here I wanted the sq.ft. '64' I Blank ECT...

Say this is a contract with "A" column asking a question and 'B' column the answer- being 8x8. C & D are just blank spaces and so on.
End of worksheet #1!
In this example worksheet #1: I wanted B2 '8x8' size to be resolved in sq.ft. as a number which is '64' in cell C2 or what ever size is answered in B2. 8x10, 8x12, 10x16,12x12 etc. Does this make sense? This was my first question!
On another worksheet #2 I have...

I 8x8 Shed I B I C I D I
1 I Description I Quantity I Pricing I Extended Pricing I
2 I 4'x4'x8' Treated I 2 I $5 I $10 I
3 I Smart Panel I 10 I $10 I $100 I
4 _________________
5 I Total I $110 I

This is #2 worksheet. It has many list of materials labeled by size of sheds- range from 8x8,8x10,8x12,12x16 etc...
In this example on worksheet #2. In column 1 row-0 '8x8 Shed' identifies this list of wood for to build this shed. When the answer in B2 on worksheet on #1 is stated as a 8x8 for example or what ever size shed it would attach a wood list from this worksheet #2. Maybe attach is the wrong word. From this I will somehow make it attach back to the contract & maybe fill in a third Worksheet for a printable fax sheet to be sent to a store. Whew! Does this make sense?