简体   繁体   English

如何使用当前工作表中的参考显示其他工作表中的图像?

[英]How to display an image from another sheet with a reference from current sheet?

I have an excel workspace with 2 sheets, in a similar manner with how they are described in this question: 我有一个带有2张纸的Excel工作区,其方式与此问题中描述的方式类似:

Excel - How to reference a value from another sheet with a reference from current sheet Excel - 如何使用当前工作表中的引用从另一个工作表引用值

How can I display images from sheet2 into sheet1 using index references from sheet1 ? 如何使用sheet1中的索引参考将图像从sheet2显示到sheet1 One of the comments suggested VBA, however, I am new to this. 其中一条评论建议VBA,但是,我是新手。 Some of the cells have missing images, and in this case, I just want to skip them. 有些单元格缺少图像,在这种情况下,我只想跳过它们。

Just to be clear, sheet2 contains a database of quiz questions, where some of the questions have a corresponding image. 需要明确的是, sheet2包含一个测验问题数据库,其中一些问题具有相应的图像。 In sheet1 , I want to select randomly some of the questions from sheet2 to form up a quiz. sheet1 ,我想从sheet2随机选择一些问题来形成一个测验。 I was able to do this with the text of the question by using the answer from the above link. 通过使用上面链接的答案,我能够用问题的文本做到这一点。 However, I want to display the corresponding images from sheet2 whenever is the case. 但是,我想在任何情况下都显示来自sheet2的相应图像。

Below are some images with my Excel workspace. 下面是我的Excel工作区的一些图像。

在此输入图像描述 在此输入图像描述

I want to display the question 154 from sheet2 onto sheet . 我想将sheet2的问题154显示在工作sheet I am able to do so with the answer from the above link. 我可以通过上面的链接回答这个问题。 However, I cannot display the adjacent image to sheet1 as in the bellow image. 但是,我无法像在波纹管图像中那样将相邻图像显示到sheet1 I tried with the command =INDEX(sheet2!C:C,($A1 - 1)*4 + 1) , but it failed. 我尝试使用命令=INDEX(sheet2!C:C,($A1 - 1)*4 + 1) ,但它失败了。

Sub FormulaMacro()
'
' FormulaMacro Macro
'

'
 ActiveCell.Value = ActiveCell.Row
 idx = ThisWorkbook.Sheets(1).Range("A" & CStr(ActiveCell.Row)).Value
 Source = "C" & CStr((idx - 1) * 4 + 1)
 Target = "C" & CStr(ActiveCell.Row)
 ThisWorkbook.Sheets(2).Range(Source).Copy
 ThisWorkbook.Sheets(1).Range(Target).Select
 ThisWorkbook.Sheets(1).Paste


 End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM