插入数据在同一行,一个按钮位于 [英] Inserting data into the same row that a button is located in
本文介绍了插入数据在同一行,一个按钮位于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个宏观该份数据从一个工作到另一个。我想一个广义的宏观该副本由作为code如下所述。同样的行号作为按钮,而不是 B2
数据
目前此code是工作的罚款;按钮文本进行更新和 MacroA
已被分配给它。我读 topleftcell
,但我无法实现它。
子MacroA()
MacroA宏
范围(I2:J2)选择。
Selection.Copy
范围(B2)。选择
Selection.Hyperlinks(1)。遵循NewWindow:=假,AddHistory:= TRUE
范围(D2)。选择
Cells.Find(什么:=,后:= ActiveCell,看着:= xlFormulas,注视:= _
xlPart,SearchOrder:= xlByColumns,SearchDirection:= xlNext,MatchCase:= _
假的,SearchFormat:= FALSE).Activate
ActiveSheet.Paste
Application.CutCopyMode =假
ActiveWorkbook.Save
ActiveWindow.Close
结束小组
解决方案
未经检验的,但可能会一起帮助你...
子仪() 尺寸C作为范围,SHT作为工作表
昏暗-d作为范围 设置SHT = ActiveSheet 集合C = sht.Shapes(Application.Caller).TopLeftCell
sht.Cells(c.Row,2).Hyperlinks(1)。遵循NewWindow:=假,AddHistory:= TRUE 随着ActiveSheet
集合D = .Cells.Find(什么:=,后:=范围(D2),看着:= xlFormulas,_
注视:= xlPart,SearchOrder:= xlByColumns,SearchDirection:= xlNext,_
MatchCase:= FALSE,SearchFormat:= FALSE)
sht.Range。(I2:J2)复制d .Parent.Save
.Parent.Close
结束与 Application.CutCopyMode =假
结束小组
I have created a macro which copies data from one worksheet to another. I want a generalized macro which copies data from the same row number as that of button, instead of B2
as mentioned below in the code.
Currently this code is working fine; the button text is updated and MacroA
has been assigned to it. I read about topleftcell
, but am unable to implement it.
Sub MacroA()
'
' MacroA Macro
'
Range("I2:J2").Select
Selection.Copy
Range("B2").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Range("D2").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
End Sub
解决方案
Untested, but might help you along...
Sub Tester()
Dim c As Range, sht As Worksheet
Dim d As Range
Set sht = ActiveSheet
Set c = sht.Shapes(Application.Caller).TopLeftCell
sht.Cells(c.Row, 2).Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
With ActiveSheet
Set d = .Cells.Find(What:="", After:=.Range("D2"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
sht.Range("I2:J2").Copy d
.Parent.Save
.Parent.Close
End With
Application.CutCopyMode = False
End Sub
这篇关于插入数据在同一行,一个按钮位于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文