选择随机行并执行操作 - select 范围内的多行
Selected random rows and do stuff - select multiple row on range
看起来很简单,但我正在努力...
我有这个简单的代码 select 黑色单元格范围内的整行,这是完全随机的,基于当前数据。
因为单元格 F5 F7 F9 F13 是空的,所以 select 是整行。
因此,我希望将第 1 列 [A] 和第 8 列 [H] 的值更改为“Estoque”,颜色为浅蓝色。
我坚持这一点。有什么帮助吗?
On Error Resume Next
Columns("H:H").SpecialCells(xlCellTypeBlanks).EntireRow.Select
一个特殊的单元格相交组合
-
-
这会将 Estoque
写入所用范围的第 H
列的所有空单元格。它还会将Estoque
写入第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
看起来很简单,但我正在努力...
我有这个简单的代码 select 黑色单元格范围内的整行,这是完全随机的,基于当前数据。
因为单元格 F5 F7 F9 F13 是空的,所以 select 是整行。
因此,我希望将第 1 列 [A] 和第 8 列 [H] 的值更改为“Estoque”,颜色为浅蓝色。
我坚持这一点。有什么帮助吗?
On Error Resume Next
Columns("H:H").SpecialCells(xlCellTypeBlanks).EntireRow.Select
一个特殊的单元格相交组合
这会将
Estoque
写入所用范围的第H
列的所有空单元格。它还会将Estoque
写入第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