View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Harry
 
Posts: n/a
Default question on macro

btw,
in my email below, the underscores miss, but in excel i have the linebreaks
correct....

"Harry" schreef in bericht
...
JMB,

I managed to get this macro working ones. It was giving me all ranges in a
message box.
But after that first time I keep getting an error message when it reaches
"For Each x In .Range".
The error says something like "Error 424 during execution, object needed"

The complete test of the macro in my actual workbook reads :

Sub test()
Dim x As Range
Dim FoundCell As Range

With Blad2
For Each x In .Range("A1", .Cells(.Rows.Count, 1).End(xlUp))
With Blad1.Rows("1:1")
Set FoundCell = .Find(what:=x.Value, after:=.Cells(1, 1),
LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows,
searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
If Not FoundCell Is Nothing Then
With .Parent
MsgBox .Range(FoundCell, .Cells(.Rows.Count,
FoundCell.Column).End(xlUp)).Address
End With
Else: MsgBox "Not Found"
End If
End With
Next x
End With

End Sub