Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Could somebody let me know if there is a better way to perform the loop function in the code below. Currently the "Do Until" loop starts at sheet 4 (This part will always be the same) and continues to loop until it reaches sheet 14 (this is fine unless there is a new sheet added or one taken away) How would I perform the loop until there are no worksheets left to activate instead of specifying the number of sheets Thanks in advance. Sub Update_Database() ' Clear Current Data Application.Worksheets("Data").Activate Range("A4:I4").Select Range(Selection, Selection.End(xlDown)).Select Selection.ClearContents Dim i As Integer i = 3 Do Until i = 14 i = i + 1 Application.Worksheets(i).Activate Range("A4:I4").Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy Sheets("Data").Select Range("A1").Select Selection.End(xlDown).Select ActiveCell.Offset(1, 0).Range("A1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Loop End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Little more advice on this code | Excel Discussion (Misc queries) | |||
Trying to improving existing code (portion of) | Excel Programming | |||
Code advice please... | Excel Programming | |||
Improving code.....For Next | Excel Programming | |||
Need advice and code help with working with *.dbf files in Excel 97 | Excel Programming |