VBA – 使用button调用函数到列中的每个单元格

通过点击一个button,我想将一个函数应用到列中的每个单独的单元格,并在另一列中输出纯粹的结果。 任何build议将不胜感激!

战略:

循环遍历A的整个列,从A1开始,直到我打空行。 这将是第一个循环,其中将有一个计数器告诉我列中有多less条数据,

第二个循环将预先创build的函数应用于每一条数据,并将其输出到不同的列。

我上个星期才刚刚拿起VBA,我不完全确定我会如何做到这一点。

我希望这至less可以让你开始。 更多信息和更好的问题将导致我为您提供更好的答案。

Sub Button1_Click() Dim LastRow As Long If Range("A1") <> vbNullString And Range("A2") <> vbNullString Then LastRow = Range("A1").End(xlDown).Row ' how many rows have data within the column End If With Range("B1:B" & LastRow) 'Last row in A so you know how many rows to use .FormulaR1C1 = "=yahooPage(RC[-1])" .Value = .Value 'Removes the formula and leaves only the values. End With End Sub