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:
Sub Cleann()
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Application.EnableEvents = False
    
    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 SubEnd Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,207,438
Messages
6,078,554
Members
446,348
Latest member
ncm3208

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