Question

pick NULL rows and then copy I am working on EXCEL 2010 vba on Win 7.

I need to find data rows with NULL in one column. And copy them to another range in the same worksheet.

Option Explicit
    Sub find_null_entries()
      Dim ActSheet As Worksheet
      Dim myRange As Range
      Dim null_counter As Integer
      Dim res_rng As Range

      null_counter = 0
      Set ActSheet = ActiveSheet
      Set myRange = Selection

      Range("D1").Value = "NULL rows"

      For Each c In myRange
        If c.Value Is "NULL" Then
            null_count = null_count + 1
        res_rng  // copy the data entry to another range in the same worksheet, e.g. column D
        End If
     Next c
   End Sub

e.g.

  item     value
  person1  NULL   // find this row and then copy the **WHOLE** row to another range in the same worksheet
  person2  18

UPDATE

  copy "person1  NULL" to another two columns  
  example: from A2:B2  to  D2:E2 

I have 5000 rows of data but maybe have 100 rows with "NULL". I need to find them and copy to toehr columns.

Any help would be appreciated .

Was it helpful?

Solution

UPD:

Sub find_null_entries()
    Dim myRange As Range
    Dim c As Range
    Dim null_counter As Long

    Set myRange = Intersect(Selection, ActiveSheet.UsedRange)

    Range("D1").Value = "NULL rows"

    For Each c In myRange
        If c.Value Like "*NULL*" Then
            null_counter = null_counter + 1
            Range("D1").Offset(null_counter).Resize(, 2).Value = c.Offset(, -1).Resize(, 2).Value
        End If
    Next c
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top