Hi, all:
I'm using a macro to check if a column contains data, and if so, copy its row to another worksheet. It's working great as long as there's data in the column I'm searching. If there's no data in that column, instead of doing nothing, it copies the header row over. How can I prevent it from copying the header row if there are no results in that column? I'm actually not sure why it's doing that in the first place, as the range I specified leaves out row 1, which is the header row. And, it doesn't copy the header row if there are any other rows that have data in that column.
Thanks in advance for any guidance!
I'm using a macro to check if a column contains data, and if so, copy its row to another worksheet. It's working great as long as there's data in the column I'm searching. If there's no data in that column, instead of doing nothing, it copies the header row over. How can I prevent it from copying the header row if there are no results in that column? I'm actually not sure why it's doing that in the first place, as the range I specified leaves out row 1, which is the header row. And, it doesn't copy the header row if there are any other rows that have data in that column.
Thanks in advance for any guidance!
Code:
Sub CopyStuff()
Dim bottomL3 As Integer
Dim x3 As Integer
bottomL3 = Sheets("Data").Range("U" & Rows.Count).End(xlUp).Row: x3 = 1
Dim c3 As Range
For Each c3 In Sheets("Data").Range("U2:U" & bottomL3)
If c3.Value <> "" Then
c3.EntireRow.Copy Worksheets("Data3").Range("A" & x3)
x3 = x3 + 1
End If
Next c3
End Sub