HOME > �����e�N�j�b�N > Excel VBA > �����ݒ�֘A�̃e�N�j�b�N > �Z���������Ō�������iFind���\�b�h�ƈ���SearchFormat�j

�Z���������Ō�������iFind���\�b�h�ƈ���SearchFormat�j�bExcel VBA

�����ݒ�֘A�̃e�N�j�b�N

�Z���������Ō�������iFind���\�b�h�ƈ���SearchFormat�j

(Excel 2002/2003/2007/2010)

Find���\�b�h�̈���SearchFormat��True�ɂ���ƃZ���̏����������ł��܂��B�������AFindNext���\�b�h�ł͏����̌������ł��Ȃ��̂ŁA�����𖞂������ׂẴZ������������Ƃ��́A2��ڈȍ~�̌�����Find���\�b�h���g�p���܂��B
����SearchFormat��Excel 2002�ȍ~�Ŏg�p�”\�ł��B

���̃T���v���́A�u�������ʁv�\�̒��Ŕw�i�F���Ԃ̃Z�����������A�ŏ��l�E�ő�l�E���v�����߂܂��B

���T���v����

Sub Sample()
    Dim c As Range
    Dim Rng As Range
    Dim firstAddress As String
    
    Application.FindFormat.Clear
    Application.FindFormat.Interior.Color = vbRed
    
    Set c = Range("��������").Find(What:="*", SearchFormat:=True)
     
    If c Is Nothing Then
        MsgBox "�Y���f�[�^�͂���܂���"
        Exit Sub
    Else
        firstAddress = c.Address
        Set Rng = c
        Do
            Set c = Range("��������").Find(What:="*", _
                                           After:=c, _
                                           SearchFormat:=True)
            If c Is Nothing Then Exit Do
            If c.Address = firstAddress Then Exit Do
            Set Rng = Union(Rng, c)
        Loop
    End If
    
    With WorksheetFunction
        MsgBox "�ŏ��l�F" & .Min(Rng) & vbCrLf & _
               "�ő�l�F" & .Max(Rng) & vbCrLf & _
               "���v�@�F" & .Sum(Rng)
    End With
End Sub