Private Sub CommandButton1_Click()
'B,C,D 欄位隱藏
Range(Columns(2), Columns(4)).Hidden = True
'
Dim U As Integer
Set RngHead = Range("A1")
DataCunt = Range("A65536").End(xlUp).Row
'A 欄位值空白隱藏
For U = RngHead.Row To DataCunt
If (Trim(Cells(U, 1)) = "") Then
Rows(U).Hidden = True
End If
Next
End Sub
先確認資料的範圍,再Loop記錄Row,進行處理.Column則直接處理
Sub Test()
Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
Columns("B:D").Hindden = True
end sub