excel - Selecting data within a recorded macros -


i trying record macro automate formatting usage reports. reports don't have same number of rows or columns.

what want select columns , rows data. when recording if click ctrl+shift+down+right select data on report. however, if run on set of data more rows or columns won't include in selection.

is there way select starting cell end of rows or columns of available data?

using relative reference correct coding. or can put code range("a1").currentregion.select appropriate place in macro (where put top leftmost cell in place of "a1").

if want more advanced work can save current region variable , use different properties on things other select area.

for example:

sub test() dim rng range dim rw integer dim col integer  set rng = range("a1").currentregion 'choose top leftmost cell in range rw = rng.rows.count 'counts number of rows in selection col = rng.columns.count 'counts number of columns rng.select 'selects range in efficient manner rng.columns(2).select 'selects second column in range rng.rows(2).select 'selects second row in range rng.cells(1,2).select 'selects cell on first row , second column in range  end sub 

hopefully helpful. wanted expand on more things work ranges have.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -