Solved

Check for null

Posted on 2013-06-05
2
222 Views
Last Modified: 2013-06-09
I need to skip this step if A2 of the Manual Sheet is null.  Is there a way to do that?

Dim lastCol As Long, lastRow As Long

   
    With Sheets("Manual")
        'lastCol = .Cells(2, .Columns.Count).End(xlToLeft).column
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        .Range("A2", .Cells(lastRow, 1)).Copy
        '.Range("A2", .Cells(Rows.Count, "A")).Copy
       .Range("A2:A300").Copy
    End With

   
    With Sheets("Cus_tmp")
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        If lastRow = 1 And .Cells(1) = "" Then lastRow = 0
        .Cells(lastRow + 1, "A").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    End With
0
Comment
Question by:leezac
2 Comments
 
LVL 13

Assisted Solution

by:Shanan212
Shanan212 earned 150 total points
Comment Utility
if sheets("Manual").range("A2").value <> vbnullstring then

end if

Open in new window

   
Use above: It checks to see if A2 is not equal to null. You can put your code inside the if-statement so that it will only run if A2 is not equal to null.
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 350 total points
Comment Utility
Hi,

Depending on whether you mean 'Null' or 'Empty'...

If Not(IsEmpty(Worksheets("Manual").Range("A2"))) Then
   With Sheets("Manual")
        'lastCol = .Cells(2, .Columns.Count).End(xlToLeft).column
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        .Range("A2", .Cells(lastRow, 1)).Copy
        '.Range("A2", .Cells(Rows.Count, "A")).Copy
       .Range("A2:A300").Copy
    End With

   
    With Sheets("Cus_tmp")
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        If lastRow = 1 And .Cells(1) = "" Then lastRow = 0
        .Cells(lastRow + 1, "A").PasteSpecial Paste:=xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    End With 
End If

Open in new window


OR

If Not(IsNull(Worksheets("Manual").Range("A2"))) Then
...
End If

Open in new window



PS. Note I used the Worksheets() collection, not Sheets() like you did.

BFN,

fp.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now