excel - CountIf of values from cells in rows between two designated dates into different worksheet with VBA -


i have userform allows user enter "from" , "to" dates search through data corresponds date range user selects. in spreadsheet, date in column a, , there series of data corresponds date in following columns each row through column w. i'm trying develop code can take 2 dates , @ rows have date falls entered date range in column a, , count responses in each of columns within rows have dates within specified range. i'd put count values specific cell each response's count in separate worksheet within same workbook. there 6 defined responses each possible response column, countif function seems me logical.

this sounds rather complicated, best way summarize it. i'm open using autofilters or else, must done using vba, , if uses autofilter, must returned pre-autofilter screen @ end of sub.

edit:

ok, guess wasn't clear. first question, reason why goes w because there couple other items associated each row not relevant analysis. columns relevant data responses columns d through w. there 1 date entered each row, , in column (you can ignore/skip columns b & c). each column (in case, question on survey), there 6 defined possible responses entered.

so, example, d3 "strongly agree", "somewhat agree", "somewhat disagree", "strongly disagree", "no response", or "not sure/not applicable". case of questions associated each column. therefore, want able pull row has date falls within 2 designated dates (beginning date , end date of range), , looks across row columns d through w , counts number of 6 possible responses (described above) each column ( or "question"). want value of counts each possible response within each column copied specific cell in worksheet (in case, sheet3).

yes, meant needs filter through column responses fall within specified date range, , run countifs each of possible responses each of 16 columns in rows met date criteria column a. make sense?

i open using kind of advanced filter or autofilter, if there other ideas out there sort through dates in column based on 2 userform designated dates, corresponding rows 16 question columns , count number of each of 6 possible responses each question, , put count designated cell on worksheet (sheet3).

i've tried countif , copy , paste each possible response each column after attempting autofilter, wasn't filtering it. seems if got work, wouldn't efficient way of doing it. here's code 2 of responses 1 column example of coding attempt (the full code accounts 6 possible responses 15 columns, seemed overly long include here):

 private sub cbokdateenter_click()  dim ws worksheet     set ws1 = thisworkbook01.sheets("sheet1")  range("a1:w" & lr)     .autofilter field:=1, criteria1:=">=" & tbenterdate01, operator:=xland,          criteria2:="<=" & tbenterdate02  dim sum01a, sum01b variant  sum01a = application.worksheetfunction.countif(sheets("sheet1").range("d2:d5000"),     "strongly disagree")     worksheets("sheet3").range("j12").value = sum01a sum01b = application.worksheetfunction.countif(sheets("sheet1").range("d2:d5000"), "somewhat disagree")     worksheets("sheet3").range("j13").value = sum01b end sub 

any appreciated! thanks!

i not sure why use columnw 15 columns (don't have idea of where!) curious whether (for running in new sheet):

sub macro1()     range("d3").select     activecell.formular1c1 = _         "=countifs(sheet1!r2c1:r5000c1,"">=""&r1c1,sheet1!r2c1:r5000c1,""<=""&r2c1,sheet1!r2c:r5000c,rc1)"     activecell.copy     application.cutcopymode = false     selection.copy     range("e3:w3").select     activesheet.paste     range("d3:w3").select     application.cutcopymode = false     selection.copy     range("d4:d8").select     activesheet.paste end sub 

this assumes: in sheet (not sheet1) a1 contains start date, a2 end date , a3:a8 6 possible responses. based on record macro, trust can adjust required (if there!) or come further details help.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -