0 then move to row 4, then row 5 the" />
开发者

Excel - Use VBA to modify a cell based on the sum of other cells in the row. Loop

开发者 https://www.devze.com 2023-02-27 05:44 出处:网络
In my sheet I would like to hit a button and loop through a series o开发者_高级运维f rows and change A3 to contain \"x\" if sum(C3:F3) = 0 and \"\" if sum(C3:F3) > 0 then move to row 4, then row 5 the

In my sheet I would like to hit a button and loop through a series o开发者_高级运维f rows and change A3 to contain "x" if sum(C3:F3) = 0 and "" if sum(C3:F3) > 0 then move to row 4, then row 5 then row 6, etc.

Any help would be appreciated.

Thanks.


do you mean in row 3 use the sum of row 3, in row 4 use the sum of row 4 and put the x also in row 4 and so on?

The easiest is to just use either use the index function (use the easy one where the index is the row into your array, or just write a little program that copies the formulas down, then you have everything automatically correct thanks to the relative references.

If you would post your code / show the row/column setup one could easily answer with the code and/or formulas


No need for VBA. Put this formula in A3 and fill down:

=IF(SUM(C3:F3)=0,"x","")


You can use spreadsheet functions in VBA code, like so:

Dim Res As Variant
Worksheets("MySheet").Activate
Res = Application.WorksheetFunction.SUM("A1:C100")

The worksheet function will act on the currently active worksheet, so be sure to set that first.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号