How to Use find function to Search for text in merged cells in a sheet

vimal_uae

New Member
Joined
Jul 13, 2013
Messages
11
Hi friends,

i have to update 'summary' sheet by searching date in 'data' sheet and selecting certain cells below searched date. i wrote below code to do same, but i'm getting "Run-time error '91': Object variable or with block variable not set " for below code.

My search date text will always be in merged cells. (think this is the reason for error)

Code:
Cells.Find(What:=Find, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

Please help me to correct it..

The full code i written is;

Code:
Sub Update()    
    Dim Find As String
    Dim Start As Range
    Dim Last As Range
    
    Sheets("Summary").Select
    If Range("A3").End(xlToRight) <> Date Then
    Do Until ActiveCell = Date
    Set Start = Range("A3").End(xlToRight)
    Set Last = Start.Offset(0, 1)
    Start.AutoFill Destination:=Range(Start, Last), Type:=xlFillDefault
    Range("A3").End(xlToRight).Select
    Loop
    End If
    
    Range("A4").End(xlToRight).Offset(0, 1).Select
    
    Do Until ActiveCell.Offset(-1, 0) = ""
    Find = ActiveCell.Offset(-1, 0).Value
    
    Sheets("Data").Select
    
    Cells.Find(What:=Find, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    
    ActiveCell.Offset(1, 2).Select
    
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("Summary").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
     :=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
     :=False, Transpose:=False
    Range("A4").End(xlToRight).Offset(0, 1).Select
    Loop
    
    
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,216,077
Messages
6,128,685
Members
449,463
Latest member
Jojomen56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top