复制可变单元格值excel宏中的值

时间:2017-12-07 08:02:26

标签: excel excel-vba excel-formula vba

请使用

找到附在此处的快照

快照显示A1单元格值从1到19不等,

C1包含从数字到数字变化的值,我需要完整数字和值的行和列。

如E和F列表示(我已手动输入)

enter image description here

2 个答案:

答案 0 :(得分:0)

将此公式输入cel C1:

=VLOOKUP($A$1,$E$1:$F$19,2,FALSE)

它将查找您在E列的A1中输入的数字,并从F列返回相应的值。

答案 1 :(得分:0)

我相信以下内容会符合您的期望:

Sub foo()
Dim ws As Worksheet: Set ws = Sheets("Sheet1") 'The sheet where you have to enter your data
For i = 1 To 19
    ws.Range("A1").Value = i 'change the value of A1 from 1 to 19 in a loop
    ws.Cells(i, 5).Value = i 'write the value in the sheet Result
    ws.Cells(i, 6).Value = ws.Range("C1") 'get the calculated value from C1
Next i
End Sub