vba - Looping with ranges not allowing Range(Cells,Cells) only Range("A:A") -


background:

i have array of 7 x 30 cells loop through. each of 30 columns (dim j), looping through rows (dim i) 1 see if value present , if start copying range of rows 2 through 7.

in attempting use (e.g.):

sheets("name").range(cells(i+1,1),cells(i+7,1)).copy 

i getting 1004, application-defined or object-defined error, have been able alleviate using:

sheets("name").range("a" & i+1 & ":a" & i+7 & ").copy 

error on line code:

sheets("rm").range(cells(i + 6, 2), cells(i + 13, 2)).copy 

issue:

this has worked items known columns, unsure how proceed variable column, well. know doesn't work:

sheets("name").range(cells(i+1,j),cells(i+7,j)).copy 

i need find way fit range model without cells work j, variable column.


question:

is there way make work using range without using cells?

my guess following, believe uses incorrect syntax:

sheets("name").range(columns(j) & i+1 & ":" & columns(j) & i+1).copy  

any appreciated!

edit: added error 1004 name issues section.

try prefacing cells( call sheet i.e. range(sheets("sheet1").cells(1, 1), sheets("sheet1").cells(2, 2))

when omit sheet in call cells or range default reference selected sheet, if you're calling sheets(unselected sheet).range(cells(1, 1)) gets confused between sheet you're referring to.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -