in Excel use name from namebox ( range ? ) in VBA -


what want select range b2:b5and give name, above cells a1 , b1 there namebox , type name: "my_test_range" here , hit enter.

  1. the word range official name range described above in excel?

then want loop trough range b2:b5 using vba , make cells right of ranged cells 1.

  1. how do above?

i want named range, because find name "options_for_red_car" or "options_for_blue_car" easier read b2:b5 etc., if dozen such ranges.

range important object in excel object model. here 1 of thousands of references information ranges:

http://msdn.microsoft.com/en-us/library/office/ff838238(v=office.15).aspx

seems like named-ranges powerful , useful , if you're going start playing vba you'll find them more , more useful.

to loop through cells in range can following:

sub loopthroughrangecells()  dim cell each cell in excel.thisworkbook.sheets("sheet1").range("a2:c6").cells     msgbox cell.address next  end sub 

although better create object reference variables when doing above , use `named-range':

sub loopthroughrangecells()  dim cell dim s excel.worksheet                     '<<creates object variable set s = excel.thisworkbook.sheets("sheet1")  '<<the object variable references our target sheet  '<<using object variable , named range following code simplified  each cell in s.range("helloworld").cells     msgbox cell.address next  end sub 

in above i've done msgbox cell.address within loop can change - might experiment , try change cells right 1.

in above i've declared variant typed variable cell. standard practice call each member of collection cells cell though no object cell exists in object model. different collection worksheets collection of intuitive object worksheet


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -