Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Location: Washington
Posts: 2
Cool Formula(s) for area with more than four sides

I'm new to this type of thing (posting messages). I'm trying to create a formula(s) that will give me the area of a home with many exterior sides. The worksheet will allow for the direction of the wall; up, down, left or right, and the length of each wall.

The shape I am using goes something like this: Up 3, Right 1, Up 2, Right 2, Up 1, Right 2, Down 2, Right 2, Down 4, Left 2, Up 1 , Left 1, Up 1, Left 1, Down 1, Left 1, Down 1, and Left 2.

I know it is a complex shape, but all angles are right angles, so it shouldn't be impossible, not that anything is impossible. Common sense says just to do it my head and write it down, but the program is for my neighbor, and I want to make it as simple as possible.

Thanks Brad
  #2   Report Post  
Mangesh Yadav
 
Posts: n/a
Default

Hi BradHaberman

Please try the following function: Enter the following code in a standard
module. And then in a cell, use the function as follows:
=myArea(A1:A18,B1:B18)

this is assuming that:
1. Your values are in cells A1:A18, and directions are in cells B1:B18
2. You represent the directions as u, d, r, l (for up, down, right, left)


'------------------------------
Function myArea(myValues As Range, myDirections As Range)

If myValues.Cells.Count < myDirections.Cells.Count Then
MsgBox "The 2 ranges you entered are not equal"
End If

n = myValues.Cells.Count

ReDim v(1 To n)
ReDim d(1 To n)

For i = 1 To n
v(i) = myValues(i)
d(i) = myDirections(i)

If d(i) = "d" Or d(i) = "l" Then
v(i) = -v(i)
End If
Next i

If Application.WorksheetFunction.Sum(v) < 0 Then
MsgBox "The area does not close" & " " &
Application.WorksheetFunction.Sum(v)
End If

h = 0
a = 0
For j = 1 To n
If d(j) = "u" Or d(j) = "d" Then
h = h + v(j)
End If

If d(j) = "r" Or d(j) = "l" Then
a = a + (h * v(j))
End If
Next j

myArea = a

End Function

'------------------------------



Regards

Mangesh




"BradHaberman" wrote in message
...

I'm new to this type of thing (posting messages). I'm trying to create a
formula(s) that will give me the area of a home with many exterior
sides. The worksheet will allow for the direction of the wall; up,
down, left or right, and the length of each wall.

The shape I am using goes something like this: Up 3, Right 1, Up 2,
Right 2, Up 1, Right 2, Down 2, Right 2, Down 4, Left 2, Up 1 , Left 1,
Up 1, Left 1, Down 1, Left 1, Down 1, and Left 2.

I know it is a complex shape, but all angles are right angles, so it
shouldn't be impossible, not that anything is impossible. Common sense
says just to do it my head and write it down, but the program is for my
neighbor, and I want to make it as simple as possible.

Thanks Brad


--
BradHaberman



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
paste formulas between workbooks without workbook link ron Excel Discussion (Misc queries) 3 April 22nd 23 08:11 AM
Problem with named formula's nathan Excel Worksheet Functions 0 January 21st 05 05:07 PM
Formulas Stan Excel Worksheet Functions 3 January 21st 05 03:58 PM
How to make Excel run limited number of formulas on a given worksh John Excel Discussion (Misc queries) 0 January 12th 05 05:29 PM
calculating formulas for all workbooks in a folder Chad Excel Worksheet Functions 3 November 13th 04 06:22 PM


All times are GMT +1. The time now is 02:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"