アプリ版:「スタンプのみでお礼する」機能のリリースについて

Excel2010でVBAでマクロを作ろうとしていますが、
FindNextで次検索をしても、一番上のセルだけしか検索できません。
どこかおかしな箇所はあるでしょうか…

B列に「a」がある行のA列のセルに「b」を入力したいです。
B列には「a」があるセルは2セル以上あります。

-----------------------------------------------------
Dim a As Range
Dim firstAddress As String

With ActiveSheet.Range("B:B")
Set a = .find("a", LookAt:=xlWhole)
if Not a Is Nothing Then
firstAddress = a.Address
do
Cells(a.Row, 1).Value = "b"
a = .FindNext(a)
Loop Until a.Address = firstAddrss
End If
End With
-----------------------------------------------------

A 回答 (2件)

どうぞ~



Dim a As Range
Dim firstAddress As String

With ActiveSheet.Range("B:B")
Set a = .Find("a", LookAt:=xlWhole)
If Not a Is Nothing Then
firstAddress = a.Address
Do
Cells(a.Row, 1).Value = "b"
Set a = .FindNext(a)
Loop Until a.Address = firstAddressEnd If
End With
    • good
    • 2
この回答へのお礼

ありがとうございます!
オブジェクト変数はSetで代入しないとだめなんですね。助かりました。

お礼日時:2014/12/08 22:57

転記ミス


Loop Until a.Address = firstAddress
End If
End With
    • good
    • 1

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!