Rammed up on empty cell code

Castyel

New Member
Joined
Jul 8, 2012
Messages
21
I running a report that is dymaic and the number of rows change and I need to make mandatory cells. Now I may just be tired but I cant seem to get it to see there is something in the cell and it always comes up with blank when it finds a line with a 1. plus can this work fork more then 2 cells code bellow. range is only 3 row long for testing

Sub manditory1()
For Each i In Range("S47:S50")
If i = 1 Then
For Each cell In Sheets("Multi").Range("D" & ActiveCell.Row, "F" & ActiveCell.Row)
If IsEmpty(ActiveCell) Then
break = x
Cancel = True
Exit For
End If
Next cell

End If

Next i


If break = x Then
MsgBox "Mandatory field not completed"

Else
End If

End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Which cells are you trying to check?

Is it only the cells in columns D to F in the same row as the active cell?

Also what are break and x?
 
Upvote 0
There is up to 8 columns I need to make sure are non blank. and theyh can be text as well as numbers.
break and x is my tired brains way of testing this
 
Upvote 0
just tired that no change. I know there is a figure in the feild but it does not seem to care. I'm wondering if it is not viewing it as activecell or not.

I have used:
Sub Mandatory()
Dim cell As Range
For Each cell In Sheets("sheet1").Range("H5,H6,H7,H8,H11,H12,H13,H14,H15")
If IsEmpty(cell.Value) Then
MsgBox "Mandatory feild no filled in if unalbe please list as NA "
Application.Goto cell
Cancel = True
Exit For
End If
Next cell

Send_Form_To_Inboxes

End Sub

on another page of the work book and it works fine but does not fit this
 
Upvote 0
What is the range you want to check?

In the first code it appeared to be cells in columns D to F, now it's H5:H15?
 
Upvote 0
Columns D & F H5:H15 was to show how the other code I was using and was working.
I have to look for column's D,F,G,H,J,M,N,P & Q but when I tired to add more then two to Range("D" & ActiveCell.Row, "F" & ActiveCell.Row) with errored
 
Upvote 0
I'm not even sure if the "D" & ActiveCell.Row is working as I don't know if its using the row where i = 1 or the row that was active on the sheet when the macro was run.
 
Upvote 0
When the code starts ActiveCell will be the active cell on the active worksheet.

It really would help if you explained exactly which cells you want to check.

It's kind of hard to help without knowing that.

Also which piece of code are you having problems with?
 
Upvote 0
is the a way to set the cell found by the macro to active (not by saying "
Worksheets("Sheet1").Range("B5").Activate)

I'm running a report that grows and I have put in code so when someone makes changes it puts a 1 in column S hence if i = 1. This tells my code that i on that row there have been changes. I then need it to make sure all cells need have been filled in.

If I knew the code that when the for each i found an i = 1 to set that as an activecell then my code would work but I can't find anyone to tell me that and i don't know how to make it look for an empty cell with using "D" & Activecell or knowing the cello like D48.

in the code I posted with the columns H shows how it works when I know the row for the cells but as it has to work for any row found that has an i = 1 and has to check columns
D,F,G,H,J,M,N,P & Q to see if they are empty
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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