特定の列に特定の列の空白がある特定の列に問題があります。これは、コードをリードしています:xlDown空白のセルを選択していません
レンジ(FieldName.Offset(1)、FieldName.End(xlDown))は、それが空白で停止しているため、細胞のすべてを選択しないために
を選択します。ブランクの直前のセルのXYZを入力します。
xlupがこの問題を解決することはわかっていますが、フィールドの最後のセルが空白の場合、そのセルは変更されずに次のセルに移動します。私はコードを変更して、xlupを利用し、下のセルが列内で空白になるのを避けるようにする方法についてはわかりません。私は "ABC"という名前の列を持っています。この列には、すべての行が取り込まれ、フィルタリングされたデータの最後の行として呼び出すためにpingできますが、これを行う方法がわかりません。
マイコードあなたはこのコードを使用することができます
Sub SelectDown()
Dim FieldName As Range
Dim rng As Range, res As Variant, lrow As Long
Set rng = ActiveSheet.AutoFilter.Range.Rows(1)
res = Application.Match("Errors", rng, 0)
'Finds the Specific Error'
rng.AutoFilter Field:=res, Criteria1:="*-SHOULD BE XYZ*"
'Only Shows rows that have something that matches the filter criteria
lrow = ActiveSheet.Cells(Rows.Count, res).End(xlUp).Row + 1
If ActiveSheet.Range(Cells(1, res), Cells(lrow, res)).SpecialCells(xlCellTypeVisible).Cells.Count > 1 Then
Set FieldName = Range("A1:BZ1").Find("COLUMN NAME")
'If field isnt present shows message
If FieldName Is Nothing Then
MsgBox "Field Name was not found."
End If
'Changes the Selection to XYZ if there is a change present
Range(FieldName.Offset(1), FieldName.End(xlDown)).Select
Selection.FormulaR1C1 = "XYZ"
'Changes the Color of the fields changed to Yellow
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
End With
Else
End If
End Sub
。SELECT'フィールド名の場合は何もThen''の 'Else'部の'FieldName'を見つけるための' Find'メソッドが成功したことを確認してください。 –