Hello,
I need your help, i have 2 columns that are not on the same sheet, the first one is a table and the second one is updated at each opening of the excel file.
I would like to compare both columns, and if a data is in the column 2 and not in the column 1, add it at the end of the 1st column.
I can't copy the whole column because it is linked to a Sharepoint.
This is my code right now.
I tryied to be as clear as possible, but if it is not, tell me i will try to do it another way.
Thank you.
I need your help, i have 2 columns that are not on the same sheet, the first one is a table and the second one is updated at each opening of the excel file.
I would like to compare both columns, and if a data is in the column 2 and not in the column 1, add it at the end of the 1st column.
I can't copy the whole column because it is linked to a Sharepoint.
This is my code right now.
Code:
Sub LinkSheetToSharePoint()
SiteURL = "myURL" 'URL to site (without trailing slash)
TargetSheetName = "Feuil1" 'Target Excel sheet name
ViewGUID = "{B3C3255D-40A3-4583-8461-A54EA8237FFB}" 'View GUID (can be obtained from the Edit View page URL)
ListName = "Supplier" 'List to be linked
Set TableList = ThisWorkbook.Sheets(TargetSheetName).ListObjects.Add(SourceType:=xlSrcExternal, _
Source:=Array(SiteURL & "/_vti_bin", ListName, ViewGUID), _
LinkSource:=True, _
Destination:=ThisWorkbook.Sheets(TargetSheetName).Range("A1"))
TableList.Name = ListName
End Sub
Sub RecoverData()
'Find "Name" in Row 1
Dim x As Workbook
'## Open both workbooks first:
Set x = Workbooks.Open(Application.ActiveWorkbook.Path & "\Suppliers ex Morpho.xlsx")
With x.Sheets("Database").Rows(1)
Set t = .Find("Vendor name", lookat:=xlPart)
'If found, copy the column to Sheet 2, Column A
'If not found, present a message
If Not t Is Nothing Then
Columns(t.Column).EntireColumn.Copy _
Destination:=ThisWorkbook.Sheets("Feuil2").Range("A1")
Else: MsgBox "Column Name Not Found"
End If
End With
With x.Sheets("Database").Rows(1)
Set b = .Find("Vendor account", lookat:=xlPart)
'If found, copy the column to Sheet 2, Column A
'If not found, present a message
If Not b Is Nothing Then
Columns(b.Column).EntireColumn.Copy _
Destination:=ThisWorkbook.Sheets("Feuil2").Range("B1")
Else: MsgBox "Column Name Not Found"
End If
End With
x.Close
End Sub
I tryied to be as clear as possible, but if it is not, tell me i will try to do it another way.
Thank you.