+ Reply to Thread
Results 1 to 1 of 1

How can I make a macro ignore blank cells? - Blank Cells have formulas

  1. #1
    Registered User
    Join Date
    08-20-2012
    Location
    here
    MS-Off Ver
    Excel 2010
    Posts
    1

    How can I make a macro ignore blank cells? - Blank Cells have formulas

    Help - Save-invoice-data1.xlsThis is my first time trying to use a macro and i am running into a issue. The below macro will ignore the rows if it is completely blank with no formulas. However i have formulas in ever cell for example =IF(K21="","",VLOOKUP(K21,Data!A:B,2,0)*J21). Even though in the formula i am telling the cell to be blank the macro is not reading it as a blank. Any help would be greatly appreciated.



    Sub Button2_Click()

    Dim rng As Range
    Dim temp As Variant
    Dim i As Long
    Dim a As Long
    Dim rng_dest As Range

    Application.ScreenUpdating = False

    i = 1

    Set rng_dest = Sheets("Invoice data").Range("A:R")

    ' Find first empty row in columns A:R on sheet Invoice data

    Do Until WorksheetFunction.CountA(rng_dest.Rows(i)) = 0

    i = i + 1

    Loop

    'Copy range B21:S37 on sheet Invoice to Variant array

    Set rng = Sheets("Invoice").Range("B21:S37")

    ' Copy rows containing values to sheet Invoice data

    For a = 1 To rng.Rows.Count

    If WorksheetFunction.CountA(rng.Rows(a)) <> 0 Then

    rng_dest.Rows(i).Value = rng.Rows(a).Value

    i = i + 1

    End If

    Next a






    Application.ScreenUpdating = True
    Last edited by mz1161; 04-30-2013 at 10:40 AM. Reason: Added Attachment

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1