1

I developed a macro that imports a column from one sheet to another in the same Workbook. This works, but now what I want is that when I modify a cell in the first sheet, it doesn't crush it in the other sheet. Instead I would like it to add it to the bottom of the other sheet.

Public Sub Click()

 Sheets("PTR").Range("B6").Select
 lRow = Worksheets("Analyse").Range("C6").End(xlDown).Row
 Worksheets("Analyse").Range("C6:C" & lRow).Copy Destination:=Sheets("PTR").Range("B6:B" & lRow)
 Application.CutCopyMode = False

End Sub
Petay87
  • 1,700
  • 5
  • 24
  • 39
Souma
  • 129
  • 1
  • 1
  • 13

1 Answers1

0

Is this what you are trying? (Untested)

I have commented the code so you shouldn't have a problem understanding it. Still if you do, simply ask :)

Public Sub Click()
    Dim wsI As Worksheet, wsO As Worksheet
    Dim lRowWsI As Long, lRowWsO As Long

    '~~> Set your output sheet
    Set wsO = ThisWorkbook.Worksheets("PTR")
    '~~> Find the last row where the data needs to go
    lRowWsO = wsO.Range("B" & wsO.Rows.Count).End(xlUp).Row + 1

    '~~> Set Input Sheet
    Set wsI = ThisWorkbook.Worksheets("Analyse")

    With wsI
        '~~> Find Last Row to get the range you want to copy
        lRowWsI = .Range("C" & .Rows.Count).End(xlUp).Row
        '~~> Do the final Copy
        .Range("C6:C" & lRowWsI).Copy Destination:=wsO.Range("B" & lRowWsO)
    End With

    Application.CutCopyMode = False
End Sub

To find the last row, you may want to see THIS post.

Community
  • 1
  • 1
Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
  • I tried ur solution ..but it did just reimport the old column not the modified one ..But the problem is that i just want to import the modified cells not all of them – Souma Aug 12 '15 at 14:09
  • so correct me if I am wrong, if c10, c30 and c12 changed then you want to copy only those 3 cells? – Siddharth Rout Aug 12 '15 at 14:20
  • exactly ..and i wanna add them at the buttom – Souma Aug 12 '15 at 19:42
  • In that case [this](http://stackoverflow.com/questions/13860894/ms-excel-crashes-when-vba-code-runs/13861640#13861640) will get you started... – Siddharth Rout Aug 13 '15 at 05:23