Home > Software engineering >  Many conditions to select the same parts
Many conditions to select the same parts

Time:10-25



If Cells (AAA, "A")=Cells (CCC, "C"), Then changed to 'If Cells (AAA, "A") & lt;> Cells (CCC, "C"), Then the
Different parts before one is chosen to perform no problem, after a part is to choose the same how does not perform, thank you for your answer!!
 Sub foreach () 
Dim AAA, CCC, K

For AAA=2 To 8
For CCC=2 To 8
If Cells (AAA, "A") & lt;> Cells (CCC, "C"), Then 'If Cells (AAA, "A")=Cells (CCC, "C"), Then the
GoTo 100
End the If
Next CCC
K=K + 1
Cells (K + 1, "E")=Cells (AAA, "A")
Cells (K + 1, "F")=Cells (AAA, "B")

100:
Next AAA
End Sub

CodePudding user response:

Such a simple function should use the goto
The building Lord you how hard it is

CodePudding user response:

 Sub foreach () 
Dim AAA, CCC, K
K=0
For AAA=2 To 8
For CCC=2 To 8
If Cells (AAA, "A") & lt;> Cells (CCC, "C"), Then the
'If Cells (AAA, "A")=Cells (CCC, "C"), Then the
K=K + 1
Cells (K + 1, "E")=Cells (AAA, "A")
Cells (K + 1, "F")=Cells (AAA, "B")
End the If
Next CCC
Next AAA
End Sub

CodePudding user response:

Thank you for your attention!!
Your program I tested, if not, your help watching, or to help test!!!!!!!!!!

CodePudding user response:

 
Sub foreach ()
Dim AAA, CCC, K
K=0
For AAA=2 To 8
For CCC=2 To 8
If Cells (AAA, "A")=Cells (CCC, "C"), Then the
'If Cells (AAA, "A")=Cells (CCC, "C"), Then the
K=K + 1
Cells (K + 1, "E")=Cells (AAA, "A")
Cells (K + 1, "F")=Cells (AAA, "B")
The Exit For
End the If
Next CCC
Next AAA
End Sub



Sorry sorry I try this tested

CodePudding user response:

The above is to choose the same part of the code

This is A list of your code and C column is not
 
Sub foreach ()
Dim AAA, CCC, K, Flag
K=0
For AAA=2 To 8
Flag=False
For CCC=2 To 8
If Cells (AAA, "A")=Cells (CCC, "C"), Then the
Flag=True
The Exit For
End the If
Next CCC
If Flag=False Then
K=K + 1
Cells (K + 1, "E")=Cells (AAA, "A")
Cells (K + 1, "F")=Cells (AAA, "B")
End the If
Next AAA

End Sub

CodePudding user response:

Thank you very much! You can use!
May be I don't have a clearly stated, I "D" column is not listed data, actual it is C, D or more columns of data as long as Ren Yilie data meet the corresponding columns in front of the data in the display area shows the complete data, I add the code you gave me a cycle results "K value" how all wrong, not free coverage is line (each column data may have a few hundred) help help

 Sub foreach () 
Dim AAA, CCC, K
K=0
For AAA=2 To 8
For CCC=2 To 8
If Cells (AAA, "A")=Cells (CCC, "C"), Then the
'If Cells (AAA, "A")=Cells (CCC, "C"), Then the
K=K + 1
Cells (K + 1, "E")=Cells (AAA, "A")
Cells (K + 1, "F")=Cells (AAA, "B")
The Exit For
End the If
Next CCC
Next AAA
End Sub
  •  Tags:  
  • VBA
  • Related