If a cell is not blank in a range
Macro Title:
|
Worksheet Variable:
|
Row Reference Variable:
|
Worksheet Name:
|
Test From Row Number:
enter the first row number of a cell from which you want to begin testing |
Test To Row Number:
enter the last row number of a cell which you want to test |
Test from Column Number:
enter the first column number of a cell from which you want to begin testing |
Test to Column Number:
enter the last column number of a cell which you want to test |
Output Column Number:
enter the column number of the column in which you want to return the results |
Value if test is True:
enter the value that you want returned if at least one cell in a range has a value |
Value if test is False:
enter the value that you want returned if all of the cells in a range are blank |
First Comment:
' |
Second Comment:
' |
Sub If_cell_is_not_blank_in_range()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'calculate if a cell is not blank in a range by looping through each cell in the specified range
For x = 5 To 8
If ws.Application.WorksheetFunction.CountBlank(ws.Range(ws.Cells(x, 3, ws.Cells(x, 5))) > 0 Then
ws.Cells(x, 6) = "Has Value"
Else
ws.Cells(x, 6) = "No Value"
End If
Next x
Next x
End Sub
Sub If_cell_is_not_blank_in_range()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'calculate if a cell is not blank in a range by looping through each cell in the specified range
For x = 5 To 8
If ws.Application.WorksheetFunction.CountBlank(ws.Range(ws.Cells(x, 3), ws.Cells(x, 5))) > 0 Then
ws.Cells(x, 6) = "Has Value"
Else
ws.Cells(x, 6) = "No Value"
End If
Next x
Next x
End Sub