我试图创建一个宏以在指定的列中查找值并保存其位置以备将来使用。要查找的值位于另一张纸上。最终目标是能够使用充满位置的数组将信息从几列复制到另一张纸上。
下面是创建我的列表的代码。...
Dim rng As Range
Dim TempSheet As Worksheet
'Copy list of Vendor IDs to be manipulated
sheets(4).Range("E4:E5000").Select
Set rng = Nothing
On Error Resume Next
Set rng = Selection.SpecialCells(xlCellTypeVisible)
rng.Copy
On Error GoTo 0
Set TempSheet = Sheets.Add
TempSheet.Range("A1").Select
Selection.PasteSpecial (xlValues)
'After Pasting values, change format to number format
[A:A].Select
With Selection
.NumberFormat = "general"
.Value = .Value
End With
'Remove duplicates from list
Range("A:A").RemoveDuplicates Columns:=1
就像我说的...。我什至不知道从下一部分编码开始...
答案 0 :(得分:0)
您可以使用find函数确定列的位置;将其放入您的搜索值循环中:
k = .Rows(1).Find(What:=SEARCHVALUE, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Column
'may want to look at partials... verify that
'assumed searching in only row 1 for these "headers"
使用已知的目的地,您可以使用value = value,例如:
wsd = sheets("destination")
wss = sheets("source")
wsd.columns(i).value = wss.columns(k).value