+ Reply to Thread
Results 1 to 6 of 6

VBA Do...Loop Statements

  1. #1
    Registered User
    Join Date
    03-21-2006
    Posts
    14

    VBA Do...Loop Statements

    Is there any way to combine two do...loop macros into one? I have the following macro, but it won't work:

    Sub newmonth()
    '
    ' newmonth Macro
    ' Macro recorded 5/3/2006 by
    '
    ' Keyboard Shortcut:
    '
    Dim i As Integer
    i = 1
    Range("A3").Select
    Do
    ActiveCell.Formula = "=IF(ISBLANK('[Trades Tickets (Oct).xls]Ticket (" & i & ")'!$A$2), "" "", '[Trades Tickets (Oct).xls]Ticket (" & i & ")'!$A$2)"
    ActiveCell.Offset(15, 0).Select
    i = i + 1
    Loop Until IsEmpty(ActiveCell.Offset(1, 0))
    Range("B3").Select
    Do
    ActiveCell.Formula = "=IF(ISERROR('[Trades Tickets (Oct).xls]Ticket (" & i & ")'!$B$5), "" "", '[Trades Tickets (Oct).xls]Ticket (" & i & ")'!$B$5)"
    ActiveCell.Offset(15, 0).Select
    i = i + 1
    Loop Until IsEmpty(ActiveCell.Offset(1, 0))
    '
    End Sub

    Thanks in advance for your help!!

    -Lisel

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474
    Could you explain what you Are trying to do, two loops or Next's can be done but , maybe you could spread some more detail on this...

  3. #3
    Registered User
    Join Date
    03-21-2006
    Posts
    14
    I'm trying to insert a formula into every 15th cell in column A (starting at cell A3), then inserting a different formula in every 15th cell in column B (starting at cell B3).

    Thanks for your help!!

    Lisel

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474
    Hi,
    How many times is this going to happen?? or when do you want it to stop??

  5. #5
    Registered User
    Join Date
    03-21-2006
    Posts
    14
    I want the loop for each formula to stop at row 1502.

    Thanks!

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474
    Hi there ,
    I haven't had time to get to this, here is a site at exceltip's web site about loops and such, maybe it will get you started

    http://www.exceltip.com/st/Using_Loo...Excel/628.html

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1