serenomoreno3
New Member
- Joined
- Oct 9, 2021
- Messages
- 1
- Office Version
- 2013
- Platform
- Windows
So I'm taking a civil engineering course and the teacher is teaching us some coding.
Not getting deep into the subject of the class, i'm trying to run this code but I keep getting a "Duplicate declaration in current scope" and keep getting the first line of the code in yellow.
I don't know how coding works and the one I wrote is based on what the teacher made. Any help to understand/fix this would be appreciated.
Sub Linea_Influencia()
Dim P, L As Double
Dim x(10), b(20), x(10, 10), M(10, 10) As Double
P = Worksheets("Lineas de Influencia").Cells(2, 2).Value
L = Worksheets("Lineas de Influencia").Cells(3, 2).Value
For i = 0 To 10
a(i) = i / 10 * L
b(i) = L - a(i)
Next i
For i = 0 To n
For j = 0 To 10
x(j) = j / 10 * L
If x(j) <= a(i) Then
V(i, j) = P * b(i) / L
M(i, j) = P * b(i) * x(j) / L
Else
V(i, j) = P * b(i) / L - P
M(i, j) = P * b(i) / L - P * (x(j) - a(i))
End If
Next j
Next i
For i = 0 To 10
Worksheets("Lineas de Influencia").Cells(10 + i, 1).Value = a(i)
Worksheets("Lineas de Influencia").Cells(25 + i, 1).Value = x(i)
Next i
For i = 0 To 10
For j = 0 To 10
Worksheets("Lineas de Influencia").Cells(10 + j, 2 + i).Value = V(i, j)
Worksheets("Lineas de Influencia").Cells(25 + K, 2 + i).Value = M(i, j)
Next j
Next i
End Sub
Not getting deep into the subject of the class, i'm trying to run this code but I keep getting a "Duplicate declaration in current scope" and keep getting the first line of the code in yellow.
I don't know how coding works and the one I wrote is based on what the teacher made. Any help to understand/fix this would be appreciated.
Sub Linea_Influencia()
Dim P, L As Double
Dim x(10), b(20), x(10, 10), M(10, 10) As Double
P = Worksheets("Lineas de Influencia").Cells(2, 2).Value
L = Worksheets("Lineas de Influencia").Cells(3, 2).Value
For i = 0 To 10
a(i) = i / 10 * L
b(i) = L - a(i)
Next i
For i = 0 To n
For j = 0 To 10
x(j) = j / 10 * L
If x(j) <= a(i) Then
V(i, j) = P * b(i) / L
M(i, j) = P * b(i) * x(j) / L
Else
V(i, j) = P * b(i) / L - P
M(i, j) = P * b(i) / L - P * (x(j) - a(i))
End If
Next j
Next i
For i = 0 To 10
Worksheets("Lineas de Influencia").Cells(10 + i, 1).Value = a(i)
Worksheets("Lineas de Influencia").Cells(25 + i, 1).Value = x(i)
Next i
For i = 0 To 10
For j = 0 To 10
Worksheets("Lineas de Influencia").Cells(10 + j, 2 + i).Value = V(i, j)
Worksheets("Lineas de Influencia").Cells(25 + K, 2 + i).Value = M(i, j)
Next j
Next i
End Sub