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:

[TABLE="class: grid, width: 1100"]
<tbody>[TR]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[TD="align: center"]H[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"]O[/TD]
[/TR]
[TR]
[TD]Date[/TD]
[TD]Description[/TD]
[TD]Amount[/TD]
[TD]Find[/TD]
[TD]Replace[/TD]
[/TR]
[TR]
[TD]Jan 5, 2018[/TD]
[TD]ACH Debit BOISE CITY UTILI FIRST TECH FCU B - BILL PAYMT[/TD]
[TD="align: right"]$ 40.78[/TD]
[TD]*BOISE CITY*[/TD]
[TD]BOISE CITY UTILITIES - BILL PAYMT[/TD]
[/TR]
[TR]
[TD]Feb 5, 2018[/TD]
[TD]ACH Debit BOISE CITY UTILI FIRST TECH FCU B - BILL PAYMT[/TD]
[TD="align: right"]$ 40.78[/TD]
[TD]*BOISE CITY*[/TD]
[TD]BOISE CITY UTILITIES - BILL PAYMT[/TD]
[/TR]
[TR]
[TD]Mar 5, 2018[/TD]
[TD]ACH Debit BOISE CITY UTILI FIRST TECH FCU B - BILL PAYMT[/TD]
[TD="align: right"]$ 40.78[/TD]
[TD]*BOISE CITY*[/TD]
[TD]BOISE CITY UTILITIES - BILL PAYMT[/TD]
[/TR]
[TR]
[TD]Jan 5, 2018[/TD]
[TD]ACH Debit INTERMOUNTAIN GA FIRST TECH FCU B - BILL PAYMT[/TD]
[TD="align: right"]$ 42.00[/TD]
[TD]*INTERMOUNTAIN GA*[/TD]
[TD]INTERMOUNTAIN GAS - BILL PAYMT[/TD]
[/TR]
[TR]
[TD]Feb 5, 2018[/TD]
[TD]ACH Debit INTERMOUNTAIN GA FIRST TECH FCU B - BILL PAYMT[/TD]
[TD="align: right"]$ 42.00[/TD]
[TD]*INTERMOUNTAIN GA*[/TD]
[TD]INTERMOUNTAIN GAS - BILL PAYMT[/TD]
[/TR]
[TR]
[TD]Mar 5, 2018[/TD]
[TD]ACH Debit INTERMOUNTAIN GA FIRST TECH FCU B - BILL PAYMT[/TD]
[TD="align: right"]$ 42.00[/TD]
[TD]*INTERMOUNTAIN GA*[/TD]
[TD]INTERMOUNTAIN GAS - BILL PAYMT[/TD]
[/TR]
[TR]
[TD]Apr 5, 2018[/TD]
[TD]POS Transaction ST ALPHONSUS BOISE PE 1055 N CURTIS RD[/TD]
[TD="align: right"]$ 169.00[/TD]
[TD]*SAINT ALPHONSUS*[/TD]
[TD]SAINT ALPHONSUS[/TD]
[/TR]
[TR]
[TD]Apr 5, 2018[/TD]
[TD]POS Transaction ST ALPHONSUS BOISE PE 1055 N CURTIS RD[/TD]
[TD="align: right"]$ 28.42[/TD]
[TD]*SAINT ALPHONSUS*[/TD]
[TD]SAINT ALPHONSUS[/TD]
[/TR]
[TR]
[TD]Apr 5, 2018[/TD]
[TD]POS Transaction ST ALPHONSUS BOISE PE 1055 N CURTIS RD[/TD]
[TD="align: right"]$ 78.00[/TD]
[TD]*SAINT ALPHONSUS*[/TD]
[TD]SAINT ALPHONSUS[/TD]
[/TR]
</tbody>[/TABLE]

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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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