在表列上执行数学运算

时间:2014-06-18 18:38:50

标签: excel excel-vba vba

我的任务是"优化"电子表格。我有一些代码从csv文件中提取数据,将其转储到工作簿中,然后创建一个表并执行其他一些数据。我想知道的是,如果有一种方法可以执行,让我们说,桌面上的一些简单划分只是引用标题。

示例:

Range("SurveyStaging[[Central Bandwidth Values]:[Bandwidth Values]]").Value = Range("SurveyStaging[[Central Bandwidth]:[Bandwidth]]").Value

但是工作得很好:

Range("SurveyStaging[District]").Value = Range("SurveyStaging[Central Bandwidth]").value/Range("SurveyStaging[School Bandwidth]").Value

引发类型不匹配。

如何在不必遍历列中的每个单元格的情况下了解如何执行此操作?

提前感谢你的帮助。

1 个答案:

答案 0 :(得分:1)

您必须根据自己的代码调整行和列,但我认为这样可行。

它不使用循环;它一次操纵整个范围。

Dim count1 As Double

count1 = 1

While Range("A" & CStr(RowNumber + count1)).Value <> ""
    DoEvents
    count1 = count1 + 1
Wend

count1 = count1 - 1
'the count is so that it takes an accurate number of rows to manipulate

Range("B2", "B" & CStr(count1)) = "=(RC[-1]/RC[-3])"
' you will have to put in whatever columns you'll be dividing with their NUMBER
相关问题