acos VBA Coding

Post on 12-Jan-2016

221 views 0 download

description

coding for ACOS function for lat and long

Transcript of acos VBA Coding

Sub dis1()

Dim a(510), b(510), c(10970), d(10970), r1(510), r2(510), r3(10970),

r4(10970) As Double

Dim v1, v2, v3, v4, v5 As Double

Worksheets("Sheet1").Activate

For i = 2 To 504

a(i) = Cells(i, 2)

r1(i) = (a(i) / 180) * 3.14159

b(i) = Cells(i, 3)

r2(i) = (b(i) / 180) * 3.14159

Next i

Worksheets("Sheet2").Activate

For i = 2 To 10962

c(i) = Cells(i, 2)

r3(i) = (c(i) / 180) * 3.14159

d(i) = Cells(i, 3)

r4(i) = (d(i) / 180) * 3.14159

Next i

Worksheets("Sheet5").Activate

For i = 2 To 504

For j = 2 To 10962

v1 = Sin(r1(i))

v2 = Sin(r3(j))

v3 = Cos(r1(i))

v4 = Cos(r3(j))

v5 = Cos(r2(i) - r4(j))

t = (v1 * v2) + ((v3 * v4) * (v5))

s = WorksheetFunction.Acos(t)

P = (s * 180 * 60 * 1.85) / 3.14

Cells(i, j) = P

Next j

Next i

End Sub

Syntax for mininmun number in macro of particular range

Set aq = Worksheets("Sheet3").Range("B2:B10")

mini = Application.WorksheetFunction.Min(aq)

Worksheets("Sheet4").Activate

Cells(2, 2) = mini

Small number message box.

Sub testsmall()

Dim strData As String

Dim rng As Range

Dim vValue As Variant

Dim rngCol As Range

Dim lngRow As Long

Dim rngAdd As Range

strData = "C3:C505"

Set rng = Range(strData)

vValue = Application.WorksheetFunction.Min(rng)

For Each rngCol In rng.Columns

If Application.WorksheetFunction.CountIf(rngCol, vValue) > 0 Then

lngRow = Application.WorksheetFunction.Match(vValue, rngCol, 0)

Set rngAdd = rngCol.Cells(lngRow, 1)

rngAdd.Select

With Selection

.Interior.Color = RGB(255, 0, 0)

End With

MsgBox "Smallest Value in Range(""" & strData & """) is " & vValue &

", in Cell " & rngAdd.Address & "."

End If

Next

End Sub

Smallest number node and centriod

Sub gtest()

Dim a(550), b(550), c(10970), d(10970), r1(550), r2(550), r3(10970),

r4(10970) As Double

Dim v1, v2, v3, v4, v5 As Double

Dim aq As Range

Dim min(1000), cen(550), node(550)

Worksheets("Sheet1").Activate

For i = 2 To 520

a(i) = Cells(i, 2)

r1(i) = (a(i) / 180) * 3.14159

b(i) = Cells(i, 3)

r2(i) = (b(i) / 180) * 3.14159

Next i

Worksheets("Sheet2").Activate

For i = 2 To 30

c(i) = Cells(i, 2)

r3(i) = (c(i) / 180) * 3.14159

d(i) = Cells(i, 3)

r4(i) = (d(i) / 180) * 3.14159

Next i

Worksheets("Sheet3").Activate

For i = 2 To 520

For j = 2 To 30

v1 = Sin(r1(i))

v2 = Sin(r3(j))

v3 = Cos(r1(i))

v4 = Cos(r3(j))

v5 = Cos(r2(i) - r4(j))

t = (v1 * v2) + ((v3 * v4) * (v5))

s = WorksheetFunction.Acos(t)

p = s * 3443.89849

Cells(i, j) = p

Next j

Next i

For j = 2 To 30

min(j) = 1000000

For i = 2 To 520

If Cells(i, j) < min(j) Then

min(j) = Cells(i, j)

cen(j) = Cells(i, 1)

node(j) = Cells(1, j)

End If

Next i

Next j

Worksheets("Sheet4").Activate

For i = 2 To 520

Cells(i, 1) = cen(i)

Cells(i, 2) = node(i)

Cells(i, 3) = min(i)

Next i

End Sub

Second smallest number and the Centriod and node

Sub gtest()

Dim a(550), b(550), c(10970), d(10970), r1(550), r2(550), r3(10970),

r4(10970) As Double

Dim v1, v2, v3, v4, v5 As Double

Dim aq As Range

Dim min(1000), cen(600), node(600), min2(1000), cen2(600),

node2(600), min3(1000)

Worksheets("Sheet1").Activate

For i = 2 To 520

a(i) = Cells(i, 2)

r1(i) = (a(i) / 180) * 3.14159

b(i) = Cells(i, 3)

r2(i) = (b(i) / 180) * 3.14159

Next i

Worksheets("Sheet2").Activate

For i = 2 To 30

c(i) = Cells(i, 2)

r3(i) = (c(i) / 180) * 3.14159

d(i) = Cells(i, 3)

r4(i) = (d(i) / 180) * 3.14159

Next i

Worksheets("Sheet3").Activate

For i = 2 To 520

For j = 2 To 30

v1 = Sin(r1(i))

v2 = Sin(r3(j))

v3 = Cos(r1(i))

v4 = Cos(r3(j))

v5 = Cos(r2(i) - r4(j))

t = (v1 * v2) + ((v3 * v4) * (v5))

s = WorksheetFunction.Acos(t)

p = s * ((180 * 60 * 1.852) / 3.14159)

Cells(i, j) = p

Next j

Next i

For j = 2 To 30

min(j) = 1000000

For i = 2 To 520

If Cells(i, j) < min(j) Then

min(j) = Cells(i, j)

cen(j) = Cells(i, 1)

node(j) = Cells(1, j)

End If

Next i

Next j

For j = 2 To 30

min2(j) = 1000000

For i = 2 To 520

If Cells(i, j) < min2(j) Then

min2(j) = Cells(i, j)

If min2(j) > min(j) Then

min3(j) = min2(j)

cen2(j) = Cells(i, 1)

node2(j) = Cells(1, j)

End If

End If

Next i

Next j

Worksheets("Sheet4").Activate

For i = 2 To 100

Cells(i, 1) = cen(i)

Cells(i, 2) = node(i)

Cells(i, 3) = min(i)

Cells(i, 4) = cen2(i)

Cells(i, 5) = node2(i)

Cells(i, 6) = min3(i)

Next i

End Sub

1:04 PM

HOW TO CONVERT GOOGLE EARTH MOVIES INTO YOUTUBE MOVIES

FREE - YouTube

www.youtube.com

1:02 PM

Learn Google Earth: Recording a Tour - YouTube

www.youtube.com

12:57 PM

google earth flight sim mod super speed tutorial - YouTube

www.youtube.com

12:57 PM

how to record the google flight simulator into mp4 format? -

YouTube

www.youtube.com

12:57 PM

Google Earth Flight Simulator Tutorial - YouTube

www.youtube.com