這似乎相當簡單,但我正在努力......
我有這個簡單的代碼可以根據當前資料從黑色單元格范圍中選擇整行,這是完全隨機的。
因為單元格 F5 F7 F9 F13 是空的,所以它選擇整行。
因此,我希望將第 1 [A] 列和第 8 [H] 列中的值更改為“Estoque”,顏色為淺藍色。
而我堅持這一點。請問有什么幫助嗎?
On Error Resume Next
Columns("H:H").SpecialCells(xlCellTypeBlanks).EntireRow.Select

uj5u.com熱心網友回復:
一個特殊的單元格-相交組合
Range.SpecialCells methodApplication.Intersect method這將寫入使用范圍
Estoque列H的所有空單元格。它還將寫入Estoquecolumn 的相應單元格(同一行中的單元格)A,無論它們是否為空。
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
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/361418.html
