excel - Autofill with variable number of rows -


i trying automate monthly report in excel vba final autofill based on variable number of rows change monthly change in # of clients. example: if month have 25 clients, hardcode want create 25 rows of report. in next month when have 30 clients, code still 25 , therefore miss 5 clients.

one solution trying work on count number of rows , apply autofill formula. trying find code read this: autofill range a1 c "number of rows in worksheet x."

now know doesn't work, poor best attempt:

sub fillreport() sheets("sheet1").select range("d1").select activecell.formular1c1 = "=counta(a:a)" sheets("sheet2").select range("a1:c1").select selection.autofill destination:=range("a1:c(sheets("sheet1").range("d1").select)") 

i didn't expect work wanted try anyway. can see quite vba novice...

if has insight helpful feel there should way accomplish missing on own.

thanks.

i using range value create manually make more clear.

so like:

dim myrngstr string myrngstr = "a1:d" & sheets("sheet1").range("a1").end(xldown).row 'i don't know find range("a1").autofill destination:=range(myrngstr) 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -