Cell cannot be blank

SDRBIRD

New Member
Joined
Oct 29, 2009
Messages
2
I need some help sorting out a small issues on a payroll spreadsheet

I need to ensure that all staff have departments. Staff names are entered in range A8:A60 and departments are entered in range B8:B60. I want to be able to stop the user moving away from a cell in range B8:B60 is data is present in adjacent cell in range A8:A60.

any help would be great

Many thanks


 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Try this in the module for the Worksheet:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Static OldCell As Range
    Application.EnableEvents = False
    If OldCell Is Nothing Then
        Set OldCell = Range("A1")
    End If
    If Not Application.Intersect(OldCell, Range("B8:B60")) Is Nothing Then
        If Not IsEmpty(OldCell.Offset(, -1)) And IsEmpty(OldCell) Then
            OldCell.Select
        Else
            Set OldCell = Target.Cells(1, 1)
        End If
    Else
        Set OldCell = Target.Cells(1, 1)
    End If
    Application.EnableEvents = True
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,710
Messages
5,597,702
Members
414,164
Latest member
ARTW

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
Top