• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

If cell is blank

Can an expert provide me with the code where the cell I am on is blank so I need to go to next oiece of code.

Thanks
0
Jagwarman
Asked:
Jagwarman
  • 5
  • 5
3 Solutions
 
Saqib Husain, SyedEngineerCommented:
Try either of these sequences
if activecell<>"" then
.
.
end if

Open in new window


if activecell="" then
.
.
end if

Open in new window

0
 
SeanStricklandCommented:
Can you give a little more information on what you're looking for?  Until then, here's a quick sample of some code that does this.  You can insert this into your worksheet's module.  (right-click your worksheet tab and click view code).

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If IsEmpty(Target) Then
    MsgBox "Cell is blank... do whatever."
End If
End Sub

Open in new window

0
 
JagwarmanAuthor Commented:
Sorry need to clarify this.

If the cell I am on is not blank then copy from that cell down to last non blank cell and also copy across rows. i.e. if I am on A50 and A70 is last non blank copy A50:X70 because Column X71 and beyond are blank cells

But if A50 is Blank then put out Msg" No Date"

Thanks
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Saqib Husain, SyedEngineerCommented:
If activecell <> "" then
    activecell.currentregion.copy
else
    Msgbox " No Date"
endif
0
 
JagwarmanAuthor Commented:
Thanks
0
 
JagwarmanAuthor Commented:
Hi ssaqibh

Love the code but I found a slight fault in that your code stops at first blank cell in the row but I need to get all data in that row. i.e. if C4 is blank but D4 through S4 are not blank and T4 is blank and U4 through AC4 are not blank I need to copy from C4 through AC4

Thanks
0
 
Saqib Husain, SyedEngineerCommented:
If it is one row then try

range(activecell,cells(activecell.row,columns.count).end(xltoleft)).copy
0
 
JagwarmanAuthor Commented:
Unfortunately it's not it can be many :-(
0
 
Saqib Husain, SyedEngineerCommented:
If it is many then currentregion should work otherwise then columns.count should work
0
 
Saqib Husain, SyedEngineerCommented:
Maybe you can try something like

If activecell <> "" then
    if activecell.currentregion.rows.count=1 then
        range(activecell,cells(activecell.row,columns.count).end(xltoleft)).copy
    else
        activecell.currentregion.copy
    endif
else
    Msgbox " No Date"
endif
0
 
JagwarmanAuthor Commented:
ok thanks ssaqibh
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now