• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Transfer from sheet 1 to sheet 2 with column swap

Belleke

Active Member
Hi,
I am looking for some code to transfer data from Sheet 1 to sheet 2 when value in column E is ready.
But two difficulties
The transfer should start at row 10 and values from column G should go to Column F
See example

Thanks
 

Attachments

ANKUSHRS1

Member
try below...
Code:
Sub tnf_dt()
Dim lstrw1, lstrw2, i As Long
Dim dt_sht, hst_sht As Worksheet
Set dt_sht = Worksheets("Data")
Set hst_sht = Worksheets("History")
lstrw1 = dt_sht.Cells(dt_sht.Cells.Rows.Count, 2).End(xlUp).Row
For i = 2 To lstrw1
lstrw2 = hst_sht.Cells(hst_sht.Cells.Rows.Count, 2).End(xlUp).Row + 1
If dt_sht.Range("e" & i).Value = "Ready" Then
hst_sht.Range("B" & lstrw2).Value = dt_sht.Range("b" & i).Value
hst_sht.Range("C" & lstrw2).Value = dt_sht.Range("C" & i).Value
hst_sht.Range("F" & lstrw2).Value = dt_sht.Range("G" & i).Value
hst_sht.Range("D" & lstrw2).Value = "Done"
End If
Next
End Sub
let me know if any flaw in this code
 
Top