slamdunk_269
Thành viên mới

- Tham gia
- 11/6/14
- Bài viết
- 3
- Được thích
- 0
mình chạy đoạn code ở dưới đây mà cứ bị báo lỗi là else without if.Mọi người xem hộ xem bài của mình pải sửa chỗ nào với.
Option Explicit
Dim i As Integer
Dim t As Integer
Dim n As Integer
Dim p() As Currency
Sub loisuat4ngay()
n = Sheet2.Cells(1, 3)
ReDim p(2 To n + 1) As Currency
For i = 2 To n + 1 Step 1
p(i) = Sheet2.Cells(i, 1)
Next i
t = 0
For i = 2 To n + 1 Step 1
If t = 4 And i >= 5 Then t = 0: Sheet2.Cells(i, 5) = Log(p(i) / p(i - 4))
Else: t = t + 1
End If
Next i
End Sub
Option Explicit
Dim i As Integer
Dim t As Integer
Dim n As Integer
Dim p() As Currency
Sub loisuat4ngay()
n = Sheet2.Cells(1, 3)
ReDim p(2 To n + 1) As Currency
For i = 2 To n + 1 Step 1
p(i) = Sheet2.Cells(i, 1)
Next i
t = 0
For i = 2 To n + 1 Step 1
If t = 4 And i >= 5 Then t = 0: Sheet2.Cells(i, 5) = Log(p(i) / p(i - 4))
Else: t = t + 1
End If
Next i
End Sub