dimanche 26 avril 2015

Working with Multiple Ranges in a Worksheet

I have a worksheet named Start Page which i am working with. The objective of my code is to inform the user if a cell is blank , that a value needs to be entered through a message box. I have been able to do it with the use of an If statement. See my code below:

Dim rng As Range
 Set rng = Sheets("Start page").Range("A4")
  If rng = "" Then
        MsgBox "Please enter Date from A4", vbOKCancel
        Exit Sub
    End If

However i trying to avoid using multiple If statements. The cells i am referring to and message boxes are below:

Sheets(“Start page”).range(“A4”) msgbox “Please enter First valuation Date inA4”

Sheets(“Start page”).range(“F5”) msgbox “ Please enter the BPS”

Sheets(“Start page”).range(“F7”) msgbox “ Please enter Account number”

Sheets(“Start page”).range(“F9”) msgbox “ Please enter Date”

Sheets(“Start page”).range(“F11”)msgbox “ Please enter Number of Periods”

Sheets(“Start page”).range(“F13”)msgbox “Please Enter number of Days in the Year"

Is there an efficient way of doing this ?

Aucun commentaire:

Enregistrer un commentaire