Iは、例えば、数字の列があると:のExcel VBA - 正と負の数の対を強調
1。 -1; 5; 4; 3; -3; -3; 3; -4;
複数のペアが表示されるという事実を考慮しながら、正と負の数(例:1と-1)のすべてのペアをハイライトできるマクロを作成したいとします(例3と - 3は両方とも2回出現する)。また、作業したい範囲を入力できるようにしたい。上記の例の場合
、すべての数字は5と7
を除いて強調表示されますここで私は上記の例では、これまで
Sub HighlightExercise()
Set myRange = Application.InputBox(prompt:="Sample", Type:=8)
myRange.Interior.ColorIndex = 2
For Each cell In myRange
If cell.Interior.ColorIndex = 30 Then Next
Set CValue = Cell.Value
myRange.Select
Set CFind = Selection.Find(What:=CValue.Value * -1, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)
If CFind.Value = Null Then Next
If CFind.Interior.ColorIndex = 30 Then Next
CFind.Interior.ColorIndex = 30
CValue.Interior.ColorIndex = 30
Next
End Sub
思い付いたものだ、それは「コンパイルエラーと言います、For Next For For "の条件があります。私は "Next Cell"と "Next iteration"を試しましたが、まだ何もありませんでした。私は何を得ていないのですか?
のでわからない** 'if cell.Interior.ColorIndex = 30 Then Next'の構文?この行は何をすると思われますか?また、 'If CFind.Interior.ColorIndex = 30 Then Next'? –