Home > Software engineering >  How to write VB program in excel is mainly about cycle
How to write VB program in excel is mainly about cycle

Time:10-07

Excel how to write command: numerical comparative cell A1 and B1, if A1 is less than B1 + 1 A1 data, loop until data in A1 is greater than or equal to stop when B1, ask how to write a great god gate

CodePudding user response:

To write such a "loop", do you have any difficult???
Just don't understand the building Lord really is to want to do!
What is the meaning? Cycle over again what?
Cycle "purpose" is what?
(it is necessary, or can only use loop to solve the problem?)

CodePudding user response:

In VBA to write very simple, to join the event

 Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 

Private Sub Worksheet_Change (ByVal Target As Range)
If Val (Range (" A1 ")) & lt; Then Val (Range (" B1 "))
The Do While Range (" A1 ") & lt; Range (" B1 ")
Sleep 500 'delay half a second to see the data in each 1
Range (" A1 ")=Val (Range (" A1 ")) + 1
Loop
End the If
End Sub

CodePudding user response:

The original poster said "comparative cell A1 and B1 number value, if A1 is less than B1 + 1 A1 data, loop until data in A1 is greater than or equal to stop when B1,"
In this case, simply don't need to loop,
Can directly reach the B1 - A1 A1 should add how much,

CodePudding user response:

Directly with MAX () function,
  • Related