Run Time Error

billandrew

Well-known Member
Joined
Mar 9, 2014
Messages
743
Unsure why I receiving a Run Time Error with the following code. Any help...

Thank You


Code:
With ActiveSheet.Range("A1:c25")    
    Set c = .Find(2020, LookIn:=xlValues)
    If Not c Is Nothing Then
        firstAddress = c.Address
        Do
            c.Value = "Replaced"
            Set c = .FindNext(c)
        Loop While Not c Is Nothing And c.Address <> firstAddress
    End If
    End With
 

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.
Are you looking for 2020 and want to replace it with Replaced.

If not please explain what your wanting to do.
 
Upvote 0
Try this:
Code:
Sub Find_Me()
'Modified  8/10/2018  8:11:23 PM  EDT
Range("A1:C25").Replace What:="2020", Replacement:="Replaced"
End Sub
 
Upvote 0
Meaning something like..

Code:
Sub Find_Alternative()

 Dim c As Range
 For Each c In Range("A2:C25")
 If c.Value = 2020 Then
 c.Value = "Replaced"
 End If
 Next


 End Sub
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.


With Excel there are probable 20 ways to do most anything.
Which way is fastest I do not know. I never test my scripts for speed.

And what is fast or slow is determined by the user.

Some users think 1.2 milliseconds is fast and some think it's slow.
 
Upvote 0

Forum statistics

Threads
1,216,583
Messages
6,131,557
Members
449,655
Latest member
Anil K Sonawane

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