I have in my excel worksheet a macro that gets from a page 2 values from different columns and concats them together in another ****.
this is the code i use :
Sub oui(wsName1$, wsName2$)
Dim Tbl As ListObject, C As Range, Vec, Tmp
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = ThisWorkbook.Worksheets(wsName1)
Set ws2 = ThisWorkbook.Worksheets(wsName2)
Set Tbl = ws1.Range("A1").ListObject
If Tbl.ListRows.Count > 0 Then Tbl.DataBodyRange.Delete
With ws2
For Each C In .Range("C2", .Range("C1").End(xlDown))
Vec = Split(C.Value, ",")
For Each Tmp In Vec
Tbl.ListRows.Add.Range.Columns(1) = WorksheetFunction.Trim(Tmp) & " / " & C(, -1)
Next
Next
End With
End Sub
'usage
Sub Test()
Call oui("Feuil2", "Feuil1")
End Sub
The problem i have, as you can see in my file (further down), is that if i already add a couple and write new ones it will delete the previous one.
In my sheet, Jane / Football is already shown and commented and if i click on the button to add the new ones it will delete what i add previously.
How can i fix this ? thank you
here is my file : macroproblem.xlsm
Bookmarks