sdfsdf fdgdf sddsf fggg dfg
3 Types of LoopsThere are some types of loops in VBAChoosing a Loop to Use Do...Loop: Looping while or until a condition is True For...Next: Using a counter to run statements a specified number of times For Each...Next: Repeating a group of statements for each object in a collection 1) For ... NextFor i=1 to Range("myRange").rowCount ......Next i2) For Each ... Next Dim aWorkSheet As Worksheet Dim aCell As Range Set aWorkSheet = ActiveSheet For Each aCell In aWorkSheet.UsedRange ..... Next 'UsedRange method:Returns a Range object that represents the used range on the specified worksheet. Read-only. 'aWorkSheet.UsedRange can be substituted as aWorkSheet.Range("myRange")3) Do...LoopDim Check, CounterCheck = True: Counter = 0 ' Initialize variables.Do ' Outer loop. Do While Counter < 20 ' Inner loop. Counter = Counter + 1 ' Increment Counter. If Counter = 10 Then ' If condition is True. Check = False ' Set value of flag to False. Exit Do ' Exit inner loop. End If LoopLoop Until Check = False ' Exit outer loop immediately .msgcontent .wsharing ul li { text-indent: 0; } 分享 Facebook Plurk YAHOO!
好站連結:http://tw.myblog.yahoo.com/olivia0754349
留言列表

