Home > Software engineering >  Wrote a small VBA program, running is always an error, see the along while also didn't see wher
Wrote a small VBA program, running is always an error, see the along while also didn't see wher

Time:09-19

VBA program is as follows, give advice or comments please everyone a great god,
 Private Sub based on particle counting precision filter () 
Dim As Integer I
Dim X, X1, X2, B1, B2 As Double
If the Range (" D25 "). The Value & gt; 5 Then
Range (" E4 "). The Value="https://bbs.csdn.net/topics/" "& amp; Range (" I6 ")
The Else
For I=1 To 8
If the Range (" D "& amp; "25 + I") & gt; 5 Then=
X1=Range (" I "& amp; "5 + I"). The Value
X2=Range (" J "& amp; "5 + I"). The Value
B1=Range (" D "& amp; "24 + I"). The Value
B2=Range (" D "& amp; 25 + "I"). The Value
The Exit For
Next I
X=(X1 - X2) * Log (5/B1)/Log (B1/B2) + X1
Range (" E4 "). The Value=https://bbs.csdn.net/topics/X
End the If

If I=8 Then
Range (" E4 "). The Value="https://bbs.csdn.net/topics/"> & amp; Range (" J13 ")
End the If

End Sub

CodePudding user response:

For what is wrong to say

CodePudding user response:

For I=1 To 8
Next
After I=9
So you If I=8 this judgment could not get total
This is only a matter of logic, and does not result in an error,

CodePudding user response:

reference 1st floor chewinggum response:
quote what is wrong to say

Next no for

CodePudding user response:

All commented On the Error Resume Next statement, running in the VBA IDE,
The error and then click the debugging, the cursor will stop error in the statement,
Or
In doubt may have a logical error statements in advance to set breakpoints, run through the breakpoint interrupt,

At this point can be used in the immediate window
? The variable name
Or
? The function name () function parameter
Or
Process (parameters)
Auxiliary debugging,
  •  Tags:  
  • VBA
  • Related