私は約20000行と4列のExcelのリストを持っています。このExcelシートには太字の名前が含まれており、その後の列にはそれらに関する情報が含まれています。各名前の後に、3行または4行を占める余分な情報がありますが、一貫性がありません。シートに目を通し、太字の名前がないすべての行を削除する必要があります。
1936 次
2 に答える
1
Sub deleteNonBolded()
Dim cell As Range
Dim selectRange As Range
For Each cell In Intersect(ActiveSheet.Range("A:A"), ActiveSheet.UsedRange)
If (cell.Font.Bold = False) Then
If selectRange Is Nothing Then
Set selectRange = cell
Else
Set selectRange = Union(cell, selectRange)
End If
End If
Next cell
selectRange.EntireRow.Delete
End Sub
于 2013-02-01T04:17:47.400 に答える
1
Font.Bold
現在のワークシートにある行の数を調べ、ワークシートの下部から上部のチェックまで行を繰り返して、行の最初の列のプロパティが false に設定されているかどうかを確認するマクロを作成する必要があります。 . その場合は、その行を削除します。
以下は私にとってはうまくいきます:
Sub DeleteUnboldRows()
Dim lastRow As Long
Dim currentRow As Long
'Select All the rows in the active worksheet
lastRow = ActiveSheet.UsedRange.Rows.Count
' Iterate through each row from the bottom to the top.
' If we go the other way rows will get skipped as we delete unbolded rows!
For currentRow = lastRow To 1 Step -1
'Look at the cell in the first column of the current row
' if the font is not bolded delete the row
If ActiveSheet.Rows(currentRow).Columns(1).Font.Bold = False Then
ActiveSheet.Rows(currentRow).Delete
End If
Next currentRow
End Sub
Bold
プロパティのリファレンスは次のとおりです: http://msdn.microsoft.com/en-us/library/office/aa224034%28v=office.11%29.aspx
于 2013-02-01T04:09:53.580 に答える