excel - Copy consolidated row data from multiple worksheets where a specific column is populated -


i'm looking copy range of data multiple worksheets single summary sheet based upon specific column being populated.

i'm using code found on link : https://msdn.microsoft.com/en-us/library/cc793964(v=office.12).aspx under section entitled 'copying data except column headers multiple worksheets'

it works although i've been trying modify code instead of copying whole sheet, copies rows in column 'n' populated.

i disabled line of code sets copyrng whole sheet , introduced loop check n column - got program return values present inside column n across sheets need return entire rows of these instances.

here modified code section in question :

        ' if source worksheet not empty , if last         ' row >= startrow, copy range.         if shlast > 0 , shlast >= startrow              'set range want copy             'set copyrng = sh.range(sh.rows(startrow), sh.rows(shlast))                   each cell in sh.range("n4:n4")                      if (cell.value <> "")                       set copyrng = '(trying copy entire row here..)                      end if                 next 

could in regard how go setting copyrng return entire row?

thanks

use

set copyrng = cell.entirerow 

that should select whole row copy. i'd timid using if you're doing lot of copy , pasting selects many cells won't need. if know maximum extent of data in columns might better use

set copyrng = worksheets(sheet_you_want).range("a" & cell.row & ":" & furthestcolumn & cell.row) 

as take less time complete.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -