Error 91 when trying to execute VBA code to find and replace data

Nitehawkhp

New Member
Joined
Dec 2, 2016
Messages
37
Greetings,

I'm trying to author a VBA script that will find information in column G based on criteria found in column N and replace the information in column G with the information in column O.
Here's a snipit of what my worksheet looks like:

FGHNO
DateDescriptionAmountFindReplace
Jan 5, 2018ACH Debit BOISE CITY UTILI FIRST TECH FCU B - BILL PAYMT$ 40.78*BOISE CITY*BOISE CITY UTILITIES - BILL PAYMT
Feb 5, 2018ACH Debit BOISE CITY UTILI FIRST TECH FCU B - BILL PAYMT$ 40.78*BOISE CITY*BOISE CITY UTILITIES - BILL PAYMT
Mar 5, 2018ACH Debit BOISE CITY UTILI FIRST TECH FCU B - BILL PAYMT$ 40.78*BOISE CITY*BOISE CITY UTILITIES - BILL PAYMT
Jan 5, 2018ACH Debit INTERMOUNTAIN GA FIRST TECH FCU B - BILL PAYMT$ 42.00*INTERMOUNTAIN GA*INTERMOUNTAIN GAS - BILL PAYMT
Feb 5, 2018ACH Debit INTERMOUNTAIN GA FIRST TECH FCU B - BILL PAYMT$ 42.00*INTERMOUNTAIN GA*INTERMOUNTAIN GAS - BILL PAYMT
Mar 5, 2018ACH Debit INTERMOUNTAIN GA FIRST TECH FCU B - BILL PAYMT$ 42.00*INTERMOUNTAIN GA*INTERMOUNTAIN GAS - BILL PAYMT
Apr 5, 2018POS Transaction ST ALPHONSUS BOISE PE 1055 N CURTIS RD$ 169.00*SAINT ALPHONSUS*SAINT ALPHONSUS
Apr 5, 2018POS Transaction ST ALPHONSUS BOISE PE 1055 N CURTIS RD$ 28.42*SAINT ALPHONSUS*SAINT ALPHONSUS
Apr 5, 2018POS Transaction ST ALPHONSUS BOISE PE 1055 N CURTIS RD$ 78.00*SAINT ALPHONSUS*SAINT ALPHONSUS

<tbody>
</tbody>

Code:
Sub DescriptionFINDandREPLACE()

'
' Description FIND and REPLACE
'
        
    For Counter = 6 To 60
        Range("CheckbookDescription").Select
        Findit = Range("N" & Counter)
        Replaceit = Range("O" & Counter)
[COLOR=#ff0000]        Selection.Find(What:="Findit", After:=ActiveCell, LookIn:= _[/COLOR]
[COLOR=#ff0000]            xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _[/COLOR]
[COLOR=#ff0000]            xlNext, MatchCase:=False, SearchFormat:=False).Activate[/COLOR]
        Selection.Replace What:="Findit", Replacement:= _
            "Replaceit", LookAt:=xlPart, SearchOrder:=xlByRows, _
            MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    Next


End Sub

Error code 91 (object variable not set) occurs when the RED section of code is executed.
I have looked the error up, but I don't understand how to fix the error.

Thanks to anyone that can help me resolve the error.

Rod
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
How about
Code:
Sub Nitehawkhp()
   Dim i As Long
   Dim FindIt As String, ReplaceIt As String
   
   For i = 6 To 60
      FindIt = Range("N" & i)
      ReplaceIt = Range("O" & i)
      Range("CheckbookDescription").Replace FindIt, ReplaceIt, xlPart, , False, , False, False
   Next
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,569
Messages
6,120,286
Members
448,953
Latest member
Dutchie_1

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