Hi,
I've found code which can clear cells including formats but the range is set.
Sub sbClearCells()
Range("A1:C10").Clear
End Sub
I want to remove all contents and formatting (cells have a black single line border) if the cell contains "No Data". I also need the code to remove the hourly segments in the cells above the "No Data" entries and the merged cells that has the date in it. Table example below. Hope you can see the formatting when you paste into excel.
<colgroup><col span="24"></colgroup><tbody>
</tbody>
I've also found this other code which handles merged cells but I have no idea how it could be adapted to solve my issue.
Help would be appreciated.
I've found code which can clear cells including formats but the range is set.
Sub sbClearCells()
Range("A1:C10").Clear
End Sub
I want to remove all contents and formatting (cells have a black single line border) if the cell contains "No Data". I also need the code to remove the hourly segments in the cells above the "No Data" entries and the merged cells that has the date in it. Table example below. Hope you can see the formatting when you paste into excel.
Service | Service ID | 08/01/2018 | 09/01/2018 | ||||||||||||||||||||
24-01 | 01-02 | 02-03 | 03-04 | 04-05 | 05-06 | 06-07 | 07-08 | 08-09 | 09-10 | 10-11 | 24-01 | 01-02 | 02-03 | 03-04 | 04-05 | 05-06 | 06-07 | 07-08 | 08-09 | 09-10 | 10-11 | ||
Serv1 | a | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data |
Serv2 | b | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data |
Serv3 | c | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data |
Serv4 | d | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data |
Serv5 | e | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data |
Serv6 | f | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data | No data |
<colgroup><col span="24"></colgroup><tbody>
</tbody>
I've also found this other code which handles merged cells but I have no idea how it could be adapted to solve my issue.
Private Sub CommandButton1_Click()
Dim c As Range
Dim ma As Range
For Each c In Range("A1:C10")
Set ma = c.MergeArea
If ma.Address = c.Address Then
If IsNumeric(c) Then c.ClearContents
Else
If IsNumeric(ma.Cells(1, 1)) Then ma.Cells(1, 1).Value = ""
End If
Next c
End Sub
Dim c As Range
Dim ma As Range
For Each c In Range("A1:C10")
Set ma = c.MergeArea
If ma.Address = c.Address Then
If IsNumeric(c) Then c.ClearContents
Else
If IsNumeric(ma.Cells(1, 1)) Then ma.Cells(1, 1).Value = ""
End If
Next c
End Sub
Help would be appreciated.