Home > Software engineering >  VBA to run the Do While Range (" A1: A65536 ") <> "prompt" run-time error
VBA to run the Do While Range (" A1: A65536 ") <> "prompt" run-time error

Time:09-25

Excel VBA to run the Do While Range (" A1: A65536 ") & lt;> "Tip" run-time error '13' type does not match what meaning be?

Intentions: to compare the ith row cell Bi to Ei values, find out the maximum, and then according to reach the maximum cell represents the significance of the results is written in the Fi and Gi cell,
As the original code:

Sub is take state automatically ()
Do While Range (" A1: A65536 ") & lt;> "" 'when A column of the cell is not equal to empty, loop gain status
Dim i&
For I=2 To 65536
If Cells (I, "b") & gt; ) Cells (I, "c" Cells (I, "b") & gt; Cells (I, "d") And Cells (I, "b") & gt; Cells (I, "e") Then
Cells (I, 6)="Bornege" 'output the maximum value of B, the result shows that the F, G
2 oncutdown Cells (I, 7)=""
The Else
If Cells (I, "c") & gt; Cells (I, "d") And Cells (I, "c") & gt; Cells (I, "e") Then
Cells (I, 6)="PutIn" 'output the maximum value of C, according to the results in the F, G
Cells (I, 7)="1 onborn" 'C> E output C
The Else
If Cells (I, "d") & gt; Cells (I, "e") Then
Cells (I, 6)="Seach" 'output maximum of D, the result shows in F, G
Onputin Cells (I, 7)="0" 'D> E direct output of the largest value D, according to the results in the F, G
The Else
Cells (I, 6)="CutDown" 'output maximum value E, shows in F, G)
Cells (I, 7)="0 onputin
"End the If
End the If
End the If
Next I
Loop
End Sub


Press F8 run to Do While an error, please everyone a great god is what mean? How to break

CodePudding user response:

1, the Range (" A1: A65536 ") is a collection of the Range, of course not and string comparison,
How to break?
For I=1 to 65536
If cells (I, 1)="" then exit the for
'to obtain the maximum
Next

2, you behind the code also has a problem, you'd better check worksheetfunction, there is a Max function
  •  Tags:  
  • VBA
  • Related