I have a sheet, that has 2 columns and 36 rows. Macro should do these things: 1) if cell in row 1, column 1 are not empty and cell in row 1, column 2 is empty macro should stop, else it should continue and after checking all 36 rows it should stop and do SaveAs, if no such values are found. I found this code and modified a little bit, but it doesn't work as I described:
Sub CheckRows()
Dim i As Long
For i = 12 To 47
'Criteria search
If Sheets("Claims").Cells(i, 2).Value <> "" Then
If Sheets("Claims").Cells(i, 3).Value = "" Then
Exit Sub
Else
End If
End If
Next i
ActiveWorkbook.SaveAs Filename:="myFile.xlsx", FileFormat:=56
End Sub
Could anyone help me out and tell what's wrong with the code? Thanks
your looking in column 2 and 3 ,not column 1 and 2 as you wrote... also your starting at row 12, is this correct ?
Sub CheckRows()
Dim i As Long
For i = 12 To 47
'Criteria search
If Sheets("Claims").Cells(i, 1).Value <> "" Then
If Sheets("Claims").Cells(i, 2).Value = "" Then
Exit Sub
End If
End If
Next i
ActiveWorkbook.SaveAs Filename:="myFile.xlsx", FileFormat:=56
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.