简体   繁体   English

Excel 2010:单击单元格 B1 时,将相邻单元格(A1 或 C1)的内容添加到另一个单元格

[英]Excel 2010: When Cell B1 clicked add contents of adjacent cell (A1, or C1) to another cell

I'm developing an Excel document for my own use, but I've hit a wall in getting everything to work as I want it, I don't really know much VBA, but I understand I'll probably require it to get what I want working... :)我正在开发一个 Excel 文档供我自己使用,但是我在让一切按我想要的方式工作方面遇到了困难,我不太了解 VBA,但我知道我可能需要它来获得什么我想工作... :)

What I need is, for example, when cell B1 is clicked, I want Excel to take the contents of an adjacent cell, (it could be A1 or C1), and duplicate / paste / copy it into the next blank cell of a row in another sheet .我需要的是,例如,当单击单元格 B1 时,我希望 Excel 获取相邻单元格的内容(可能是 A1 或 C1),并将其复制/粘贴/复制到一行的下一个空白单元格中在另一张纸上

I'd preferably like it to be flexible, so that I can simply duplicate it for B2 (and it would then apply for A2 or C2), since it would be required for hundreds of cells - and entering it manually constantly would be a total pain.我希望它灵活一些,这样我就可以简单地将它复制到 B2(然后它将适用于 A2 或 C2),因为数百个单元格都需要它 - 并且不断地手动输入它是一个总数疼痛。 I don't really want to use forms or check boxes...我真的不想使用 forms 或复选框...

Thanks,.谢谢,。 Luke.卢克。

Maybe I misunderstood your question but I'd go about it like this:也许我误解了你的问题,但我想 go 是这样的:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim WS As Worksheet: Set WS = Worksheets(2)
    Dim adjacent As Range: Set adjacent = Target.Offset(0, 1)
    WS.Range(adjacent.Address).Value = adjacent.Value
End Sub

暂无
暂无

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

相关问题 将单元格a1中的JSON数据提取到b1,c1,d1等中。 - Excel - Extract JSON data in cell a1, into b1, c1, d1 etc.. - Excel 如何一次将一个单元格(例如(A1; B1; C1)或数组(A1:C1))传递到Excel的XLL文件的相同C函数? - How do I pass a cell at a time, e.g. (A1; B1; C1) or an array (A1:C1) to the same C function of Excel's XLL file? Excel公式-根据B1和C1中的值添加单元格+“ .jpg”为空白 - Excel Formula - Add cell + “.jpg” based on value in B1 and C1 is blank 如果B1为空,则删除A1单元格 - Delete A1 cell if B1 is empty 如果单元格B1为“ x”,则拉出单元格A1,否则忽略 - If Cell B1 is “x”, pull Cell A1, otherwise ignore Excel-从单元格A1到AX中选择,其中在单元格B1中读取X - Excel - Selecting from cell A1 to AX, where X is read in cell B1 我必须输入单元格A1和B1,当任何一个单元格都输入了值时,我想显示A1或B1的值 - I have to cells, A1 and B1, I want to display the value of A1 or B1 when either cell have value entered vsto Excel 2010 add in-在内容引用另一个单元格和公式时获取单元格的值 - vsto excel 2010 add in - get value of cell when contents refer to another cell and formula 如果工作表 1 中的单元格 A1 等于工作表 2 中的“x”,则在工作表 1 单元格 C2 中显示工作表 2 中的单元格 B1 - If cell A1 in sheet 1 equals 'x' like in sheet 2, then display cell B1 from sheet 2 in sheet 1 cell C2 Excel / VBA - 单元格A1的变化反映在B1中,反之亦然(即变化双向流动) - Excel / VBA - Changes to cell A1 reflected in B1 and vices versa (ie changes flow both ways)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM