Kamis, 12 Juni 2014

[ExcelVBA] Alternative to range.offset which is not robust to added columns

 



I often use range.offset in lists to make similar calculations in several rows

a sub may be like this (simplified)

sub calcrows()

for each cell in range("a1.a10")

cell.offset(0,4) = cell.offset(0,3) * cell.offset(0,2)

next cell

end sub

This works OK but my problem is when I have more complicated models and more complicated subs its easy to loose "control" if I have to add or move a column, and then have to change all this offset-commands.

Can anyone point me to another approach to this sort of operations that can cope with added/moved columns.

Is it possible in any way using the titles in first row instead of column numbers in the offset-command?

regards

Torstein

__._,_.___

Posted by: Torstein Johnsen <sejohnse@yahoo.no>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar