Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

Error 91 VBA Excel

$
0
0

I got error 91 when I execute my code in VBA

There is my code

Sub Traingulation()    
 Dim table As Range
 Dim tableRows As Integer
 Dim tableCols As Integer
 Dim ws As Worksheet   

 Set table = ws.Cells
 tableRows = ws.UsedRange.Rows.Count
 tableCols = ws.UsedRange.Columns.Count

 Dim x1 As Double
 Dim x2 As Double
 Dim x3 As Double
 Dim y1 As Double
 Dim y2 As Double
 Dim y3 As Double   

 Dim r1 As Double
 Dim r2 As Double
 Dim r3 As Double    

 Dim phase1 As Double
 Dim phase2 As Double
 Dim phase3 As Double    
 Dim frequence1 As Double
 Dim frequence2 As Double
 Dim frequence3 As Double   
 Dim A As Double
 Dim B As Double
 Dim C As Double
 Dim D As Double
 Dim E As Double
 Dim F As Double   
 Dim Xu As Double
 Dim Yu As Double

 x1 = Range("L5").Value
 x2 = Range("L6").Value
 x3 = Range("L7").Value
 y1 = Range("M5").Value
 y2 = Range("M6").Value
 y3 = Range("M7").Value

 For i = 1 To table1Rows
   For j = 1 To table1Cols
     If table(i, 5).Value = 1 Then
       phase1 = table(i, 2).Value & frequence1 = table(i, 3).Value
     End If
   Next

   If table(i, 5).Value = 2 Then  
     phase1 = table(i, 2).Value & frequence1 = table(i, 3).Value
   End If
 Next

 If table(i, 5).Value = 3 Then
   phase1 = table(i, 2).Value & frequence1 = table(i, 3).Value
 End If

 r1 = -(3 * 10 ^ 8 * phase1) / 4 * 3.14 * frequence1    
 r2 = -(3 * 10 ^ 8 * phase2) / 4 * 3.14 * frequence2
 r3 = -(3 * 10 ^ 8 * phase3) / 4 * 3.14 * frequence3

 A = x3 - x1
 B = y3 - y1
 C = x3 - x2
 D = y3 - y2
 E = ((r1) ^ 2 - (r3) ^ 2) - ((x1) ^ 2 - (x3) ^ 2) - ((y1) ^ 2 - (y3) ^ 2)
 F = ((r2) ^ 2 - (r3) ^ 2) - ((x2) ^ 2 - (x3) ^ 2) - ((y2) ^ 2 - (y3) ^ 2)

 Xu = 0.5 * ((F * B) - (D * E)) / ((C * D) - (A * D))
 Yu = (0.5 * E / B) - (A * ((F * B) - (D * E))) / (B * ((C * B) - (A * B))) 

 MsgBox "Triangulation : Xu =  "& Xu & ",  et Yu =  : "& Yu & ""
End Sub

Viewing all articles
Browse latest Browse all 88854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>