我有一个Excel工作表,我希望每一列都存储在不同的工作簿中。
Zone State
North Punjab
North Haryana
South Kerala
South Chennai
O / p:应该是两本excel工作簿,一本书中包含区域,另一本书中注明
使用此代码,我可以将内容复制到现有工作簿中的新工作表中,而不能复制到新工作簿中。
Sub CopyUnique()
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Sheets("Main")
Set s2 = Sheets("Count")
s1.Range("B:B").Copy s2.Range("A1")
s2.Range("A:A").RemoveDuplicates Columns:=1, Header:=xlNo
End Sub
答案 0 :(得分:0)
请参见以下代码:
Sub CopyUnique()
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Sheets("Main")
Set s2 = Sheets("Count")
s1.Range("B:B").Copy s2.Range("A1")
s2.Range("A:A").RemoveDuplicates Columns:=1, Header:=xlNo
s2.Move
ActiveWorkbook.SaveAs ("C:\--------\Desktop\Test\New.xlsx")
'If you want close that workbook
ActiveWorkbook.Close True
End Sub