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
Bookmarks