goto next if

  • Thread starter Thread starter Miree
  • Start date Start date
M

Miree

I have 8 columns of user entered data which i need to copy into another
worksheet.
I have the code to move it over but not all 8 colums will be filled all the
time and i dont want to copy over blank lines. I want to write code to say if
cell 1 is empty donot copy go to cell 2, then if cell 2 is empty, donot copy
goto cell 3..... and so on.
it may be that random colums have data so i need it to check each one.
 
Sub MoveData()

NewRow = 1
With Sheets("Sheet1")

LastRow = 0
For ColCount = 0 To 8
LRow = .Cells(Rows.Count, ColCount).End(xlUp).Row
If LRow > LastRow Then
LastRow = LRow
End If
Next ColCount

For RowCount = 1 To LastRow
LastCol = .Cells(RowCount, Columns.Count). _
End(xlToLeft).Column
If .Range("A" & RowCount) <> "" Or _
LastCol > 1 Then

.Rows(RowCount).Copy _
Destination:=Sheets("Sheet2").Rows(NewRow)
NewRow = NewRow + 1
End If
Next RowCount
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top