Results 1 to 4 of 4

Loop using Multiple Conditions

Threaded View

rdgreen Loop using Multiple Conditions 07-24-2008, 06:03 PM
Richard Buttrey Hi, and welcome to the forum.... 07-24-2008, 07:33 PM
rdgreen Reply to post 'Loop using... 07-24-2008, 11:09 PM
Richard Buttrey Hi Doug, Try the modified... 07-25-2008, 05:19 AM
  1. #1
    Registered User
    Join Date
    07-24-2008
    Location
    Minnesota
    Posts
    4

    Loop using Multiple Conditions

    Hello,

    This is my first post! As you will see, I am a relative beginner with VBA. I am trying to do a Loop (I think a Loop Until) using two conditions, but I am getting multiple errors – mainly “Do without Loop” errors. The explanation and code are below:

    I have two tables. The first table has number of acres. The second shows whether those acres are going to be a part of the water system. So, if a "0" is in a cell in the first table, then an "N/A" is written in the second table. If a number greater than "0" is in the first table, a drop down list with "Yes" or "No" is written into the second table. (I recorded the drop-down list.) Also, I added a Private Sub in the Worksheet so that any time the first table is updated, the macro runs.

    I am probably making this harder than it needs to be, but I have spent a day trying to figure this out and it's not working!

    Any advice is greatly appreciated.

    Sincerely,
    Doug

    Sub Residential_Water_Table()
    
    'This sub puts in a "N/A", "Yes", or "No" into cells within a table to identify future sewer customers.
    'If a "0" is entered in the first table, an "N/A" is written into the second table.] 'If a number > "0" is entered in the first table, a drop down box with "Yes"
    or "No" is written into the second table.
    
    Dim i As Integer, j As Integer, x As Integer, y As Integer x = 3 y = 12 'x and y are rows
    
    i = 3
    j = 3
    'i and j are columns
    
    Do Until i = 52
    
    Worksheets("Sheet1").Cells(x, i).Select
    
    If ActiveCell = 0 Then
    
    Worksheets("Sheet1").Cells(y, j).Select
    ActiveCell.Formula = "N/A"
    Else
    End If
    
    Worksheets("Sheet1").Cells(x, i).Select
    If ActiveCell > 0 Then
    Worksheets("Sheet1").Cells(y, j).Select
    ActiveCell.Formula = ""
    With Selection.Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
            xlBetween, Formula1:="=$A$12:$A$13"
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = ""
            .ShowInput = True
            .ShowError = True
            End With
    End If
    
    ActiveCell.Offset(0, 1).Select
    i = i + 1
    j = j + 1
    
    Loop
    
    End Sub
    Attached Files Attached Files

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