PDA

View Full Version : Solved: Blank cells



Klartigue
06-06-2012, 11:32 AM
I know that this expression means if the cell is blank:


Sub Mellon()
' Copy and paste Mellon allocations into new sheet in workbook

Dim lastrow As Long
Dim i As Long
With ActiveSheet

lastrow = .Cells(.Rows.Count, "X").End(xlUp).Row
For i = 4 To lastrow

If .Cells(i, "X").Value = "" Then

With Range(.Cells(i, "A"), .Cells(i, "X")).Select
Selection.Cut
Sheets("Mellon").Select
Range("A10000").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Sheets("Blotter").Select
End With

End If

Next i

End With

End Sub

How do I write the code to say if there is text in cells in column X then copy and paste those lines into a new sheet?

Klartigue
06-06-2012, 11:36 AM
I think I got it. I just said if the cells in the column are not blank..

Sub tester()
' Copy and paste Mellon allocations into new sheet in workbook

Dim lastrow As Long
Dim i As Long
With ActiveSheet

lastrow = .Cells(.Rows.Count, "W").End(xlUp).Row
For i = 4 To lastrow

If .Cells(i, "W").Value <> "" Then

With Range(.Cells(i, "A"), .Cells(i, "X")).Select
Selection.Cut
Sheets("Sheet1").Select
Range("A10000").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Sheets("Blotter").Select
End With

End If

Next i

End With

End Sub