Find method skips over cells

H

Hydra

This code works nine times and then skips Sept, Nov, and Dec

I beleive this has something to do with merged cells, because those three
months are merged cells, however it it works on March which is also a merged
cell also merged cells.

Hydra




For MonthCounter = 1 To 12

Cells.Find(What:="$", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate

PriceAddress(Monthcounter) = ActiveCell.Address

Next Monthcounter
 
R

Ryan H

I'm not sure exactly what you are trying to accomplish, but you can try this.

Sub MonthCounter()

Dim MonthCounter As Long

For MonthCounter = 1 To 12

Cells.Find(What:="$", _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Select

PriceAddress(MonthCounter) = Selection.Address

Next MonthCounter

End Sub

If this doesn't work you will have to be more specific on what you want?
Are you getting an error thrown? What is PriceAddress? Is it a Function or
Sub that returns something? Please be more specific.

Hope this helps! If so, please click "YES" below.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top