If the formula in a cell is blank then do nothing else run code

thedeadzeds

Active Member
Joined
Aug 16, 2011
Messages
451
Office Version
  1. 365
Platform
  1. Windows
Hi Guys,

I'm struggling how to add some additional code to the below. Essentially, if the formula in Allocate!e16 is equal to blank, then do nothing, else run the below: The formula is Allocate!e16 is
Code:
=IF(E16<>0, D16, "")


Code:
Sub Payam_Naeini_New_Calls_Service_and_MOT()'Payam Naeini
    Application.ScreenUpdating = False
    Dim sh1 As Worksheet, sh2 As Worksheet
    Dim i As Long, j As Long
    Set sh1 = Sheets("Audi SMOT NC Values")
    Set sh2 = Sheets("All Data")
    
    'Filter New Call
    Sheets("Audi SMOT NC Values").Select
    ActiveSheet.Range("$A$1:$P$5000").AutoFilter Field:=4, _
        Criteria1:="New Calls"
    'Filter the relevant Contcode
    ActiveSheet.Range("$A$1:$P$5000").AutoFilter Field:=13, _
        Criteria1:=Array("Kerridge MOT", "Kerridge Service & MOT", "Non Fran Service & MOT", "Non Fran Service", "Polk MOT", _
        "Polk Service & MOT", "Polk Service", "React MOT", "React Service & MOT", "React Service", "MOT", "Service", "Kerridge Service"), Operator:=xlFilterValues
    'Filter by person
    ActiveSheet.Range("$A$1:$P$5000").AutoFilter Field:=16, _
        Criteria1:=Array("Payam Naeini")
        
    i = 1
    For j = 2 To Rows.Count
        If sh1.Cells(j, 1).EntireRow.Hidden = False Then
            
            sh1.Cells(j, 1).EntireRow.Copy
            sh2.Cells(Rows.Count, 1).End(xlUp).Offset(1).PasteSpecial xlPasteValues
        
            
            i = i + 1
            If i = Range("Allocate!e16").Value + 1 Then Exit Sub
        End If
    Next j
    Application.ScreenUpdating = True
    
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Simply add this line, as shown
Code:
   [COLOR=#0000ff] If Sheets("Allocate").Range("E16").Value = "" Then Exit Sub[/COLOR]
    'Filter New Call
    Sheets("Audi SMOT NC Values").Select
 
Upvote 0

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

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