How to avoid getting N/A in cells after clearing/VBA code

Abouya

Registered User.
Local time
Today, 06:14
Joined
Oct 11, 2016
Messages
88
Hello,

I'm using this code to clear content while leaving formulas. After i click the button to clear, I get the #N/A in those cells i cleared. Is there a way to handle this. Thanks a lot.

here is my code:

Code:
Sub NextInvoice()
    On Error Resume Next
    
    Dim rConstants As Range
   
    Range("H5").Value = Range("H5").Value + 1
    
    Set rConstants = Sheet1.Range("C5:C12").SpecialCells(xlCellTypeConstants)
    Set rConstants = Sheet1.Range("B17:J17").SpecialCells(xlCellTypeConstants)
    Set rConstants = Sheet1.Range("A20:J27").SpecialCells(xlCellTypeConstants)
        
    rConstants.ClearContents
    
End Sub
 
Also,
I noticed that i have to click clear button 3 times to clear all the designated cells. How i can delete all by one click. (This is where i understood the fact that I'm a noobie :))

Thanks
 

Users who are viewing this thread

Back
Top Bottom