Home > Software engineering >  Vb application runtime error 1004 o great god answer I just contact with vb many don't understa
Vb application runtime error 1004 o great god answer I just contact with vb many don't understa

Time:09-24

 Sub hello () 
Dim Z As Integer
Dim X As Integer
Dim As A Integer
Dim As Integer B
Dim As Integer C
Dim D As Integer
Dim E As Integer
Dim G As Integer
Dim H As Integer
Dim As Integer I
Dim J As Integer
Dim As Integer K
Dim W As Integer
Dim Y As Integer
Dim M As Integer
Dim Q As Integer
Dim As Integer L
Dim Z1 As Integer
Dim Z2 As Integer
Dim Z3 As Integer
Dim G1 As Integer
Dim G2 As Integer
Dim G3 As Integer
Dim G4 As Integer
Dim the G5 As Integer
Dim G6 As Integer
Dim Z4 As Integer
Dim E1 As Integer
Dim E2 As Integer
Dim E3 As Integer
Dim E4 As Integer
Dim E5 As Integer
Dim the E6 As Integer
Dim E7 As Integer
Dim E8 As Integer
Dim E9 As Integer
Dim E10 As Integer


For G2=7 To 17


Cells (" 2 ", "CS")=0
Cells (" 2 ", "CT")=0
Cells (" 2 ", "CU")=0
Cells (" 2 ", "CV")=0
Cells (" 2 ", "the CW")=0
Cells (" 2 ", "CX")=0
Cells (" 2 ", "CY")=0
Cells (" 2 ", "CZ")=0
Cells (" 2 ", "DA")=0
Cells (" 2 ", "DB")=0


If G2=7 Then

Z3=Cells (" 3 ", "DC"). The Value

Z2=G2

End the If


If G2=8 Then

Z3=Cells (" 3 ", "DD"). The Value

Z2=G2

End the If


If G2=9 Then

Z3=Cells (" 3 ", "DE"). The Value

Z2=G2

End the If


If G2=10 Then

Z3=Cells (" 3 ", "DF"). The Value

Z2=G2

End the If


If G2=11 Then

Z3=Cells (" 3 ", "DG"). The Value

Z2=G2

End the If


If G2=12 Then

Z3=Cells (" 3 ", "DH"). The Value

Z2=G2

End the If


If G2=13 Then

Z3=Cells (" 3 ", "DI"). The Value

Z2=G2

End the If


If G2=14 Then

Z3=Cells (" 3 ", "DJ"). The Value

Z2=G2

End the If


If G2=15 Then

Z3=Cells (" 3 ", "DK"). The Value

Z2=G2

End the If


If G2=16 Then

Z3=Cells (" 3 ", "DL"). The Value

Z2=G2

End the If


If G2=17 Then

Z3=Cells (" 3 ", "DM"). The Value

Z2=G2

End the If


For E=Z3 To Range (" A65536 "). The End (xlUp). Row
The Debug. Print E


If Cells (E, "CS") & gt; Error 1004 0 Then the program to the error, adding debug. Print E or not, the value of E is equal to zero, how to change??

Cells (E, "CS")=0

CodePudding user response:

E is equal to zero, because Z3 a value of 0 bai,
Z3 is equal To zero, because in your "For G2=7 To 17", the assignment statements in front of the Z3 assignment is 0,
It is an error, "debug", and then look at G2 value is how much, then find the corresponding Z3 assignment statements, which is of value in the cell;
Working table "to" the current activity, see if the corresponding cell without the data, or the value is 0,

You should pay attention to, your Z3 assignment statement: Z3=Cells (XX, XXXX). The Value
This "explicitly specify work table", then it is read "the current workbook currently active work table",
You in the workbook "selected worksheet" is not correct, can cause errors of execution,

the VBA code, write too bad!
  •  Tags:  
  • VBA
  • Related