0
我在兩個工作簿之間工作。
XL1是這樣在另一個範圍內查找範圍條件
StudentID |From |To
1 |2 |9
2 |20 |50
3 |0 |1
XL2日常工作簿是另一個工作簿是這樣的:
From| To
0 | 1.5 'Associate 1 with this as an ID
2 | 15 'Associate 2 with this as an ID and so on
我試圖寫在XL1代碼,將讓我
- 看0
select xl2 workbook
查找列從和到
入住XL1工作簿如果從和爲每位學生中落在和向XL2範圍,然後一個ID 關聯。要清楚(是這樣):
StudentID |From |To |ID
1 |2 |9 |2
2 |20 |50 |
3 |0 |1 |1
到目前爲止,我已經寫了這個代碼,但我似乎無法弄清楚如何獲得邏輯:
Sub getID()
Dim wb As Workbook
Dim ws As Worksheet
Dim fd As FileDialog
Dim filename As String
Dim rng As Integer
Dim counter As Integer
Dim frm As Range
Dim too As Range
Dim lngCount As Integer
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With fd
If .Show Then
FileName = .SelectedItems(1)
Else
'if user pressed CANCEL - exit sub
MsgBox "User pressed CANCEL"
Exit Sub
End If
On Error Resume Next
Set wb = Workbooks.Open(FileName)
rng = ActiveSheet.UsedRange.Rows.Count
frm = ActiveSheet.Range("AA" & rng).Select 'copy from col
too = ActiveSheet.Rang("AC" & rng).Select 'copy to col
For Each Cell In frm
if()
Next Cell
Next
End If
End With
End Sub
的例子基本上意味着
xl2.from<xl1.from<xl2.to
和
xl2.from<xl1.to<xl2.to
我希望在得到這個工作
爲什麼sumifs不起作用? – Jeeped
所以for循環中的部分實際上使0有意義。在每本工作簿中是否有多個工作簿和多個工作簿都需要通過?另外我不明白這個例子如何匹配?只有從需要匹配嗎? – UGP
涉及兩個工作簿,每個工作簿都有一個工作表。這個例子基本上意味着xl2.from
SQLserving