Prevent Error, If there is No Data,

Plokimu77

Board Regular
Joined
Oct 1, 2014
Messages
138
Good morning forum,

The macro below intends to find the last used row and clear all the borders
that were not used in the range below it, then move to a new cell and repeat the same process.

The problem is that there might be no data for a day in one of the columns,
because there was No products sold, so we get a error message,
and it will not continue to the next range.

What can I add to the code, so that it can bypass to the next columns
if there is no Data found?

Can some please assist?

Thank you

Code:
Range("H2").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("A1:B1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Clear
    ActiveCell.Offset(-11, 3).Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("A1:B1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Clear
        ActiveCell.Offset(-18, 3).Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("A1:B1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Clear
        ActiveCell.Offset(-16, 3).Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("A1:B1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Clear
        ActiveCell.Offset(-15, 3).Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Range("A1:B1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.ClearContents
    Selection.Clear
    ActiveWindow.ScrollColumn = 7
    ActiveCell.Offset(-9, -12).Range("A1").Select
        Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
End Sub
 

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.
being simplistic a error checking routine at its basic use

On Error Resume Next

just prior to where the routine is that fails
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

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