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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,050
Office Version
365
Platform
Windows
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
 

Nitehawkhp

New Member
Joined
Dec 2, 2016
Messages
37
Fluff,

Once again you have provided me with a solution that works perfectly!

THANKS!

Rod
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,050
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Forum statistics

Threads
1,081,676
Messages
5,360,441
Members
400,586
Latest member
Minty

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top