excel - Macro/VBA: Clear cells in a row based on values in a column, and loop through entire column -


i'm trying write macro in excel identify first value in row (a2) , search rest of row clear cell greater value (c2:dga2). i'd set such program loops through every row in column (a2:a400), , clears corresponding values.

i tried using following code, modified post:

sub clear_cell() dim v v = excel.thisworkbook.sheets("top line").range("b2").value  dim arr() variant arr = sheet1.range("c2:dgj2")  dim r, c long r = 1 ubound(arr, 1)     c = 1 ubound(arr, 2)         if arr(r, c) > v             arr(r, c) = ""         end if     next c next r  sheet1.range("c2:dgj2") = arr  end sub 

i modified fit needs, works first row. need getting loop through every row in first column.

thank help.

i'm trying write macro in excel identify first value in row (a2) , search rest of row clear cell greater value (c2:dga2).

from above statement, assuming ranges in same sheet. code works me if make few changes. see this

sub clear_cell()     dim long, j long     dim arr      '~~> set range here     arr = sheet1.range("a2:dgj400").value      = 1 ubound(arr, 1)         j = 2 ubound(arr, 2)             if arr(i, j) > arr(i, 1)                 arr(i, j) = ""             end if         next j     next      '~~> write sheet     sheet1.range("a2:dgj400") = arr end sub 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -