excel - Assigning Next Empty Multi-cell Range to Variable Returned by Function -


i trying use function return range object 1 x 4 in size using next empty row in worksheet can transfer values 1 range on different sheets. unfortunately can't seem figure 1 out. have tried search answer, can find 1 cell solutions.

private function assignnextrow(project string) range      dim projectsheet worksheet     set projectsheet = worksheets(project)     dim firstemptyrow range     set firstemptyrow = projectsheet.range(cells("a" & projectsheet.rows.count) _       .end(xlup).offset(1, 0), cells("d" & projectsheet.rows.count).end(xlup).offset(1, 0))     assignnextrow = firstemptyrow  end function 

so best way set range variable?

edit:

i've fixed code run, start of next sheet's range offset start when last sheet's range ended. new code follows:

private function assignnextrow(project string) range      dim projectsheet worksheet     set projectsheet = worksheets(project)     dim firstemptyrow range     set firstemptyrow = projectsheet.range("a" & projectsheet.rows.count) _       .end(xlup).offset(1, 0).resize(1, 4)     set assignnextrow = firstemptyrow  end function 

i'm not sure fix issue.

2nd edit:

what "next sheet" , "last sheet" exactly? might need provide code calls assignnextrow() -tim williams

private sub dailytransfer()     dim dailyrange variant     dailyrange = worksheets("daily").range("a3:d23").value     dim x integer, y integer, z integer, projectname string     dim entrydate date     x = 1     y = 1     z = 1     x = 1 20         projectname = dailyrange(x, 2)         entrydate = dailyrange(x, 1)         if projectname = "" exit         if wkshtcheck(projectname) = false call wkshtmake(projectname, entrydate)         y = 1 4             dim emptyrow range             set emptyrow = assignnextrow(projectname)             emptyrow(1, z).value = dailyrange(x, y)             if y = 1 y = y + 1             z = z + 1         next y     next x end sub 

this should long there's value in cola

set firstemptyrow = projectsheet.range(cells("a" & projectsheet.rows.count) _   .end(xlup).offset(1, 0).resize(1,4) 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -