Copy to next empty row is not working

DThib

Active Member
Joined
Mar 19, 2010
Messages
427
Help!

I have not had this problem before, but my macro is now copying over the current data instead of appending in the next empty row.
I need this to look at the date (today), if the data is already there, do nothing. If not today then take the data and place each instance in the next available row.

This copies multiple rows that match the criteria, but now it is overwriting the data already present in the worksheet("Workable").

Code:
Sub Wordie()


  Dim LastRow, LR As Long
  Dim i As Long
  Dim j As Long
  
    Sheets("Workable").Activate
     
    LastRow = Cells(Rows.Count, "B").End(xlUp).Row + 1
    j = 2
    For i = 1 To LastRow
    
        If Sheets("Initial Query").Cells(i, 29) <> "" And Sheets("Initial Query").Cells(i, 11) = _
        "Assigned" And Sheets("Initial Query").Cells(i, 16) = "" Then
             Sheets("Workable").Cells(j, 2) = Sheets("Initial Query").Cells(i, 2).Value
             Sheets("Workable").Cells(j, 3) = Sheets("Initial Query").Cells(i, 10).Value 
             Sheets("Workable").Cells(j, 4) = Sheets("Initial Query").Cells(i, 9).Value 
             Sheets("Workable").Cells(j, 5) = Sheets("Initial Query").Cells(i, 29).Value 
             Sheets("Workable").Cells(j, 6) = Sheets("Initial Query").Cells(i, 5).Value 
             Sheets("Workable").Cells(j, 7) = Sheets("Initial Query").Cells(i, 6).Value 
             Sheets("Workable").Cells(j, 8) = Sheets("Initial Query").Cells(i, 30).Value
             Sheets("Workable").Cells(j, 9) = Sheets("Initial Query").Cells(i, 8).Value 
             j = j + 1
        End If
    Next i
    
End Sub
I cannot figure out what is going on!

DThib
 
Last edited:

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
39,108
Office Version
365
Platform
Windows
Try
Code:
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
    j = LastRow + 1
 

DThib

Active Member
Joined
Mar 19, 2010
Messages
427
Once again Fluff,

You are the Fluffiest!

Thanks.

1 other thing I am playing with, I am trying to choose the row with the latest data for a userform that displays the information. The ID for the item may be duplicated, so I need to make the selection only pull the current data defined by a date in row A.

any ideas?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
39,108
Office Version
365
Platform
Windows
As that's a completely different question, you'd best start a new thread.
 

Watch MrExcel Video

Forum statistics

Threads
1,096,396
Messages
5,450,147
Members
405,589
Latest member
shakenblake

This Week's Hot Topics

Top