excel - How to deleting selected range of cells when range is dependent on a variable? -


i want delete cells in range g123:p10000, value of 123 in g123 keeps on changing, how can provide variable while providing range.

below can used 1 time, want use multiple times based on value in variable named 'count' changes every run deletes range only

range("g123:p10000").select selection.clearcontents 

i tried below, not working

count = activesheet.range("a1").end(xldown).row range("g$count:p10000").select selection.clearcontents 

what need .offset() , .resize() modifications range.

... count = countrows(activesheet.range("a1")) activesheet.range("g1").offset(count,0).resize(10000-count,1).clearcontents 

with

public function countrows(byval r range) long     if isempty(r)         countrows = 0     elseif isempty(r.offset(1, 0))         countrows = 1     else         countrows = r.worksheet.range(r, r.end(xldown)).rows.count     end if end function 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -