Verifying that selected cells all contain values

Johannareta

New Member
Joined
Sep 24, 2018
Messages
1
Hi everyone, I am trying to have the user select a range to input. I have been able to have set a parameter for the number of columns selected. I can not figure out what line would show error if the columns selected did not have data. Current code will be attached below:

If tablerange.Column.Count <> 5 Then
MsgBox "Must select 5 columns of data. Try again."


I'm a noob to all this so excuse my poor wording
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
.
Paste this into a Routine Module :

Code:
Option Explicit


Sub RBlank()


Dim rng As Range, cel As Range


Set rng = [A2, C5, F7, G3] 'change as required
For Each cel In rng
    If cel = "" Then
        MsgBox "Cell " & cel.Address & " is blank.", vbInformation, "Blank Cell"
    End If
Next
End Sub

You can edit the rng to include a range of cells instead of individual cells : Set rng = [A2, C1:D25, F7, G3]

This macro will work if you are referencing a small number of individual cells. If you have a large number of non-continguous cells you'll need to use
something else .. otherwise your user will be press the ENTER key for all the empty cells. Could be tiresome depending on how many cells are blank.
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,029
Members
452,542
Latest member
Bricklin

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