使用VBA Excel中的替换公式替换单元格地址

时间:2016-02-29 22:32:01

标签: excel vba replace

我想将用户的x输入替换为N2中存储的Cell Address值。例如Cells(2, i+10)J2 Cell,在单元格A2的第一个循环中,如果用户编写=J2^2并且下一个循环将是x^2,它将是B2=K^3 {1}}如果用户写了x^3等等。

    numero_formulas = InputBox("¿Cuántas fórmulas vas a ingresar?")
    Sheets("ResultadosContinua").range("I6") = numero_formulas

    For i = 1 To numero_formulas

    N2 = Cells(2, i + 10)

    formula_user = InputBox("Escribe la fórmula:" & i & "")
    Cells(2, i).Select
    Sheets("ResultadosContinua").Select
    ActiveCell.Formula = "=" & Replace(formula_user, "x", " & N2 & ")

2 个答案:

答案 0 :(得分:0)

如果你想要url: "https://chanvrequebec.com"的地址(距离activecell 4列),你需要使用它:

N2

但正如我所说,在第4次迭代后,您的代码将删除cel numero_formulas = InputBox("¿Cuántas fórmulas vas a ingresar?") Sheets("ResultadosContinua").Range("I6") = numero_formulas For i = 1 To numero_formulas n2 = Cells(2, i + 10) formula_user = InputBox("Escribe la fórmula:" & i & "") Cells(2, i).Select Sheets("ResultadosContinua").Select ActiveCell.Formula = "=" & Replace(formula_user, "x", ActiveCell.Offset(0, 4).Address(False, False)) 内的公式。

答案 1 :(得分:0)

我建议您阅读如何避免按this question使用import {Router} from 'angular2/router'; ... constructor(private _router:Router) {} ... navigate() { this._router.navigate(['ViewEmployees']); } 。我还鼓励使用您要定位的对象的全名。即.Select将起作用,但写Cells(2,10) = "Text"总是更好。然后可以将您的代码修改为:

Cells(2,10).Value = "Text"
相关问题