VBA If Not IsEmpty

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,124
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm working with a this code below that works great!

It first checks on sheet1 cell D3 to first see if there is a value before it provides a date stamp.

Here is the code:


Code:
Sub Macro16()
'
' Macro16 Macro
'
'
    Application.Cursor = xlWait  'during processing
        If Not IsEmpty(Sheet1.Range("D3").Value) Then
        
        MsgBox ("This was already executed!                                                                                          Please use the SAVE ICON at the TOP LEFT TO SAVE YOUR DOCUMENT!")
         
    Application.Cursor = xlDefault  'on completion / error
         
        Exit Sub
         
        End If
        
        Call UNLockCell
        Call AddDateStamp
    
        Call SaveAsXLSM
        
        
    Application.Cursor = xlDefault  'on completion / error
       
     
        
      
End Sub


Now my question is, when I change this code to execute it for another sheet, for example sheet10 in the code below it does not work and I can't figure it out.


Code:
Sub Macro33()
'
' Macro33 Macro
'
'
 

        If IsEmpty(Sheet10.Range("B2").Value) Then
        
        MsgBox ("The IMPORT HAS to be executed FIRST!!")
         
  
    
    
        Exit Sub
         
        End If
        
 
        
        
    Application.Cursor = xlDefault  'on completion / error
       
     
        
      
End Sub

If I type a date into sheet10 cell B2, I'd expect the MsgBox to popup
The IMPORT HAS to be executed FIRST!!
in using Macro33 above, but it does not (?).


Can someone try and help me out on this?


Thanks,
Pin
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Oh I think I know, I've reversed the code:

If IsEmpty


So, does anyone know I can write instead for its opposite;
IF IS NOT EMPTY
to be written in my 2nd code for the Macro33 I have posted here???
 
Upvote 0

Forum statistics

Threads
1,223,655
Messages
6,173,616
Members
452,525
Latest member
DPOLKADOT

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