It seems to be fairly simple but I'm struggling...
I have this simple code to select entire row from a black range of cells, which is totally random, base on the current data.
Because the cells F5 F7 F9 F13 are empty, it selects the entire row.
So, I wish to change the value from column 1 [A] and 8 [H] to "Estoque", coloured in light blue.
And I'm stuck on that. Any help, please?
On Error Resume Next
Columns("H:H").SpecialCells(xlCellTypeBlanks).EntireRow.Select
CodePudding user response:
A SpecialCells-Intersect Combination
This will write
Estoque
to all empty cells of columnH
of the used range. It will also writeEstoque
to their corresponding cells (cells in the same row) of columnA
, regardless of whether they are empty.
Option Explicit
Sub Estoque()
Dim rg As Range
On Error Resume Next
Set rg = Intersect(Range("A:A,H:H"), _
Columns("H:H").SpecialCells(xlCellTypeBlanks).EntireRow)
On Error GoTo 0
If rg Is Nothing Then
MsgBox "Nope!", vbCritical
'Exit Sub
Else
rg.Value = "Estoque"
MsgBox "Estoque!", vbInformation
End If
End Sub