If ANY CELL is empty in Col "O", then run Module45... IF NONE are blank, run Module50

ChrisOK

Well-known Member
Joined
Mar 26, 2003
Messages
601
Trying to figure out VBA Sub that will scan Column "O" starting at "O5" for any blanks/empty cells found.. <b>IF YES,</b> then run <u><i>Module45,</u></i> <b>IF NO,</b> then run <u><i>Module50.</u></i>

NOTE: (don't want to include the blanks that may be present at the base of the worksheet)...
<b>May need to refer to Col A to look for data present...</b> If yes, continue to scan down COLUMN O looking for blanks in O.
Once it sees that there is no more data in Col A, then stop looking. (don't want it to look at rows at the bottom of the sheet that don't hold any data)

Thanks!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Try:
Code:
Sub RunMod()
    Application.ScreenUpdating = False
    Dim bottomA As Integer
    bottomA = Range("A" & Rows.Count).End(xlUp).Row
    Dim rng As Range
    For Each rng In Range("O5:O" & bottomA)
        If rng = "" Then
            Call Module45
        Else
            Call Module50
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi Mumps/All:
I tried it as is but got errors, so I attempted to adjust the way "Module45" and "Module50" were written.. still having issues..???
Got this error when done this way:, it highlighted "Module36" and gave this error: <b>"COMPILE ERROR: Expected Variable or Procedure, Not Module"</b>
Any ideas how to fix??
Code:
Sub RunMod()
    Application.ScreenUpdating = False
    Dim bottomA As Integer
    bottomA = Range("A" & Rows.Count).End(xlUp).row
    Dim rng As Range
    For Each rng In Range("O5:O" & bottomA)
        If rng = "" Then
            Call Module36
        Else
            Call Module36B
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub

When I try it this way (with underscores), I get <b>"COMPILE ERROR: Sub or Function Not Defined"</b>
Any ideas how to fix??
Code:
Sub RunMod()
    Application.ScreenUpdating = False
    Dim bottomA As Integer
    bottomA = Range("A" & Rows.Count).End(xlUp).row
    Dim rng As Range
    For Each rng In Range("O5:O" & bottomA)
        If rng = "" Then
            Call Module_36
        Else
            Call Module_36B
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi Chris. The "Call" command is used to run a macro. I assumed that when you said "Module45" and "Module50", you were referring to the macros contained in those modules. The "Call" command must be followed by the name of the macro you want to run. What are the names of the two macros you want the code to run?
 
Upvote 0

Forum statistics

Threads
1,216,090
Messages
6,128,765
Members
449,467
Latest member
sdafasfasdf

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