|
▼β さん:
うまくいきました!
有難うございます。
ごめんなさい。別件で質問なのですが、Sheet1のA列に大文字で”AAA”という文字列があるか探し、あればそのセルを赤くし、結果表示もさせる、というようなものを作りたいのですが、下記のものだとエラーが出てしまいます。
解決方法を教えていただけないでしょうか。
Private Sub AAA_Click()
Dim oRange As Range
Dim c As Range
Set oRange = Cells.Find(What:="*AAA*" _
, After:=ActiveCell _
, LookIn:=xlFormulas _
, LookAt:=xlWhole _
, SearchOrder:=xlByRows _
, SearchDirection:=xlNext _
, MatchCase:=False _
, MatchByte:=False _
, SearchFormat:=False)
Set c = Selection
c.ColorIndex = vbRed
If c.Count > 0 Then
MsgBox "AAAがありました"
Else
MsgBox "AAAはありませんでした"
End If
End Sub
>▼あや さん:
>
>要件を取り違えているかもしれませんが、こういうことですか?
>
>Sub TestRed()
> Dim c As Range
> With Application.FindFormat.Interior
> .PatternColorIndex = xlAutomatic
> .Color = 255
> .TintAndShade = 0
> .PatternTintAndShade = 0
> End With
>
> If ActiveCell.Column <> 1 And ActiveCell.Column <> 2 Then Range("B1").Select
>
> Set c = Range("A1", ActiveSheet.UsedRange).Columns("A:B").Find(What:="", After:=ActiveCell, _
> LookIn:=xlFormulas, LookAt:=xlPart, _
> SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False, _
> MatchByte:=False, SearchFormat:=True)
>
> If c Is Nothing Then
> MsgBox "重複セルはありません"
> Else
> c.Select
> End If
>
> Application.FindFormat.Clear
>
> End Sub
|
|