选择excel行并插入公式 [英] Select excel row and insert formula
问题描述
您好,
我目前正在制作一张Excel工作表,我想在一个单元格中输入一个行号,然后点击一下按钮,excel将找到该行,然后运行一个宏来更新一个单元格。
我可以知道这个或任何例子的背后代码让我开始吗?
更新:
当用户点击某个范围内的单元格时,将选中该表格的整行,按钮点击(链接到宏UpdateFormula)将运行以将.Formula插入单元格。
Sub UpdateFormula()
范围(Cells(Selection.Row, 18 ),Cells(Selection.Row, 24 ))。选择
范围( anchor_variable)。公式= = Anchor1
范围( table_variable)。公式= = base_point + short_end_increment *(base_year-R $ 15)
结束 < span class =code-keyword> Sub
该代码使我能够将公式插入整个表中,但不能插入我选择的单元格中具体来说。
我想要的是只将公式插入我点击的行
谢谢:)
15)
结束 Sub
该代码使我能够将公式插入整个表中,但不能插入我专门选择的单元格中。
我想要的是只将公式插入我点击的行
谢谢:)
请参阅下面的VBA教程。
http://www.excel-easy.com/vba.html [ ^ ]
http:// www.homeandlearn.org/ [ ^ ]
http://www.tutorialspoint.com/vba/ [ ^ ]
< a href =http://www.ozgrid.com/VBA/> http://www.ozgrid.com/VBA/ [ ^ ]
http://www.ozgrid.com/Excel/free-training/ExcelVBA1/excel-vba1-index.htm [< a href =http://www.ozgri d.com/Excel/free-training/ExcelVBA1/excel-vba1-index.htmtarget =_ blanktitle =新窗口> ^ ]
使用 Worksheet.SelectionChange事件 [ ^ ],例如:
私有 Sub Worksheet_SelectionChange( ByVal 目标作为范围)
使用目标
.Range( anchor_variable)。公式= = Anchor1
.Range( table_variable) .Formula = = base_point + short_end_increment *(base_year-R
Hello,
I am currently working on an Excel sheet where I want to enter a row number into a cell, and on the click of a button, excel will locate the row and then run a macro to update a cell.
May I know the behind code for this or any examples to get me started?
Update:
When a user clicks on a cell in a range, the whole row of the table will be selected, and on button click (linked to macro UpdateFormula) will be run to insert the .Formula into the cells.
Sub UpdateFormula() Range(Cells(Selection.Row, 18), Cells(Selection.Row, 24)).Select Range("anchor_variable").Formula = "=Anchor1" Range("table_variable").Formula = "=base_point+short_end_increment*(base_year-R$15)" End Sub
The code enables me to insert the formula into the whole table but not into the cells that I have selected specifically.
What I want is to insert the formula only to the row that I am clicking on
Thank You :)解决方案15)" End Sub
The code enables me to insert the formula into the whole table but not into the cells that I have selected specifically.
What I want is to insert the formula only to the row that I am clicking on
Thank You :)
Please refer below for VBA tutorials.
http://www.excel-easy.com/vba.html[^]
http://www.homeandlearn.org/[^]
http://www.tutorialspoint.com/vba/[^]
http://www.ozgrid.com/VBA/[^]
http://www.ozgrid.com/Excel/free-training/ExcelVBA1/excel-vba1-index.htm[^]
Use Worksheet.SelectionChange event[^], for example:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) With Target .Range("anchor_variable").Formula = "=Anchor1" .Range("table_variable").Formula = "=base_point+short_end_increment*(base_year-R
这篇关于选择excel行并插入公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!