vba help - Validation File Path from range

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
976
Office Version
  1. 2010
Platform
  1. Windows
Hi Team,

I am using below code to open input files from a cell.
I want to ensure it should not be blank. Shall I use and OR Operator here.

if blank exit the Macro.

VBA Code:
'==============Validate File path=============
     If wsFolderPath.Range("b1").value = "" Or wsFolderPath.Range("b2").value = "" Or _
        wsFolderPath.Range("b4").value = "" Or wsFolderPath.Range("b6").value = "" Or _
        wsFolderPath.Range("b8").value = "" Then
       msgbox "FilePath should not be Blank in Ranges" & wbTemplate.Name, vbCritical
        GoTo Myend
    End If




Thanks
mg
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
try following & see if does what you want

VBA Code:
       Dim rng As Range
        Set rng = wsFolderPath.Range("B1:B2,B4,B6,B8")
       
        If Application.CountA(rng) <> rng.Cells.Count Then
            MsgBox "FilePath should not be Blank in Ranges" & wbTemplate.Name, vbCritical
        
       Else
       'do stuff

        End If

Dave
 
Upvote 0
Glad suggestion helped - many thanks for feedback

Dave
 
Upvote 0

Forum statistics

Threads
1,214,894
Messages
6,122,124
Members
449,066
Latest member
Andyg666

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