Solved

Check for null

Posted on 2013-06-05
2
252 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
ID: 39222907
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
ID: 39222920
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

733 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