Handling cells with !REF error when copying and pasting range

tomleitch

Board Regular
Joined
Jan 3, 2012
Messages
189
Hi all,

I have some code that is processes data that is held in the clipboard from another sheet.

It's a bit clunky - but it works ok.... basically I go to the second worksheet, select all and copy and then go back to the first sheet and click the button to run the code that imports data.

There is quite a bit of data that it processes - between 4000 to 20000 lines and each line has about 8 different columns that I use to get data from.

Everything works fine - however sometimes there is just the odd entry where in the report field someone has started the entry with an equals or a minus sign so it then appears in my source sheet as !REF error - which gives me a problem when I try and copy and paste it.

I don't really want to loop through all the lines or anything to fix as it would be quite a slow process.

Can anyone give me any advice on the best way to go about sorting this or what options might be?

Thanks
Tom
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
if the plus and minus are unimportant, and the REF doesn't occur until you process you could just remove the offending items
VBA Code:
    Columns("A:H").Select
    Selection.Replace What:="+", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

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