Skip

kenpcli

Board Regular
Joined
Oct 24, 2017
Messages
129
I have a vb looking to pull rows that return a certain value and place at the bottom, but it errors if it doesnt find a row with that name. Sometimes the sheet will have it and sometimes not, how do I tell it to ignore it and move on if that name doesnt appear. Here is the code so far:

With Columns(3)
.Replace "Totals For NO INSURANCE", True, xlWhole, , False, , False, False
Set Ar = .SpecialCells(xlConstants, xlLogical).Areas
.Replace True, "Totals For NO INSURANCE", xlWhole, , False, , False, False
End With
 

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
maybe add on error resume next?
Code:
[COLOR=#ff0000]
on error resume next[/COLOR]
With Columns(3)
.Replace "Totals For NO INSURANCE", True, xlWhole, , False, , False, False
Set Ar = .SpecialCells(xlConstants, xlLogical).Areas
.Replace True, "Totals For NO INSURANCE", xlWhole, , False, , False, False
End With
[COLOR=#ff0000]resume next[/COLOR]
 
Upvote 0
maybe add on error resume next?
Code:
[COLOR=#ff0000]
on error resume next[/COLOR]
With Columns(3)
.Replace "Totals For NO INSURANCE", True, xlWhole, , False, , False, False
Set Ar = .SpecialCells(xlConstants, xlLogical).Areas
.Replace True, "Totals For NO INSURANCE", xlWhole, , False, , False, False
End With
[COLOR=#ff0000]resume next[/COLOR]
I think that last line of code should be this instead..

On Error GoTo 0

in order to turn the error checking off.
 
Upvote 0
Thank you, that worked
I noticed you clicked the "Like" link for my message but not for Roderick_E's message. Just reminding you that the code I posted in my message was written by Roderick, not me... all I did was offer a correction to a type of "typo" in his code.
 
Upvote 0

Forum statistics

Threads
1,223,152
Messages
6,170,389
Members
452,323
Latest member
GoJones

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