non blank cells

hothhg

New Member
Joined
Nov 28, 2011
Messages
3
I have a must requirement that if A1 has data, B1 should be either / or some other user defined text but should never be blank.
This is just an example, I would also like to extend the logic to complete list e.g. from A1 to A25 and so on.

Trying data validation and some macros already discussed in this forum but no luck.

Please help
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Do you want to force data entry in column B as you are entering data in column A or do you want to check column B for blanks after all the data has been entered in column A?
 
Upvote 0
Dear Mumps,

I want to force data in column B as I enter data in column A e.g. * or / (any predefined text).
 
Upvote 0
Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter a value in column A.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim response As String
    If Target.Offset(0, 1) = "" Then
        Do
            response = InputBox("Please enter a value for cell " & Target.Offset(0, 1).Address(0, 0) & ".")
            If response <> "" Then
                Target.Offset(0, 1) = response
                Exit Do
            ElseIf response = "" Then
                MsgBox "You must enter a value for cell " & Target.Offset(0, 1).Address(0, 0) & ".", vbOKOnly, ""
            Else: Exit Do
            End If
        Loop
    End If
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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