If Cell range is nothing then

fari1

Active Member
Joined
May 29, 2011
Messages
362
Code:
Dim dcell As Range, cellbelowd As Range
Set dcell = Worksheets("info").Cells.Find("Description", , xlValues, xlWhole, , , False)
Set cellbelowd = Worksheets("info").Cells.Find("*", dcell, xlValues, xlWhole, xlByColumns, xlNext)
                If cellbelowd Is Nothing Then
exit sub

in my above code, i want to do is to check if the next cell under the cell description is blank, if it is blank then exit sub.

but this code is not working somehow, any help
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Code:
Dim dcell As Range
Set dcell = Worksheets("info").Cells.Find("Description", , xlValues, xlWhole, , , False)
If Not dcell Is Nothing Then
    If dcell.Offset(1).Value = "" Then Exit Sub
End If
 
Upvote 0
'SlowHand' here... I see that you already rec'd a good answer - just as already typed and in case you want to verify that the sheet exists...

Rich (BB code):
Option Explicit
    
Sub exa()
Dim wksInfo     As Worksheet
Dim dcell       As Range
    
    On Error Resume Next
    Set wksInfo = ThisWorkbook.Worksheets("info")
    
    If Err.Number = 9 Then
        MsgBox "Sheet ""info"" does not exist", vbOKOnly + vbInformation, "Error"
        On Error GoTo 0
        Exit Sub
    End If
    On Error GoTo 0
    
    Set dcell = wksInfo.Cells.Find("Description", , xlValues, xlWhole, , , False)
    
    If dcell Is Nothing Then
        MsgBox "Didn't find ""Description""", vbOKOnly + vbInformation, "Error"
        Exit Sub
    ElseIf dcell.Offset(1).Value = vbNullString Then
        Exit Sub
    Else
        MsgBox "'some more code"
    End If
End Sub
 
Upvote 0
hi, its not about the sheet, i just wanted to see if a cell is b blank or not, the sheet is always there. thanks anyways for your help, greatly appreciated, will use this somewhere else, a i'm working on too much extensive project, thanks again
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

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