宏是新的,我正在寻找一点洞察力。通过宏复制excel中的值
我正在寻找一个基于所选框中的值的单独显示表格中的单元格信息。
我有5个单元格根据它的评级从名为“电影”的表中拉出一个标题给电影。我还在它旁边有5个单元格,返回一年,然后是5个单元格,并与评分相邻。这里是什么样子:
A B C
______________________________________________________
1 | Eternal Sunshine of the Spotless Mind | 2004 | 8.5 |
2 | 3 Idiots | 2009 | 8.2 |
3 | Before Sunrise | 1995 | 8.1 |
4 | Groundhog Day | 1993 | 8.1 |
5 | (500) Days of Summer | 2009 | 8.0 |
我想要让这个被选中A1单元格时,该地块从电影表中的电影工作拉。
Worksheet = movies
Table = Movies
Column = Plot
我需要能够匹配标题和年份,因为我的Movies表中有多个具有相同名称的电影。
这里是我到目前为止创建与测试宏(结果1是A1的名字,结果2是A2的名称等):
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("Result1")) Is Nothing Then
MsgBox Target.Address & " is Result1."
ElseIf Not Intersect(Target, Range("Result2")) Is Nothing Then
MsgBox Target.Address & " is Result2."
ElseIf Not Intersect(Target, Range("Result3")) Is Nothing Then
MsgBox Target.Address & " is Result3."
ElseIf Not Intersect(Target, Range("Result4")) Is Nothing Then
MsgBox Target.Address & " is Result4."
ElseIf Not Intersect(Target, Range("Result5")) Is Nothing Then
MsgBox Target.Address & " is Result5."
Else
End If
End Sub
我想复制的情节将所选单元格中的电影放入单元格B7中。
例如,如果选择了Result1,它将在电影表中找到无光泽心灵的永恒阳光,并在B7中输出它的情节。
感谢您的帮助!
编辑:这是电影表的样子:
ID Title Year Duration Rating Plot
_____________________________________________________________________________________________________________________________________________________________________________________
| 1 | (500) Days of Summer | 2009 | 95 min | 8.0 | An offbeat romantic comedy about a woman who doesnt believe true love exists, and the young man who falls for her. |
您可以上传您的文件,并给我们的链接,或让我们知道哪里是你的电影台和它的结构是什么。 – 2013-03-27 19:29:36
文件非常大,但我会在OP – rjbogz 2013-03-27 19:36:01