EXCEL VBA Type Mismatch Error "13" Assigning Date Data Type to Variable (Solved) -


i'm trying loop through column of dates, , date within 2 other set dates (first day of week, last day of week) or (first day of month, last day of month).

when go assign date in column variable, type mismatch error.

sub jobsdue(byref datestart date, byref dateend date) dim lastrow integer lastrow = sheet1.cells(rows.count, "b").end(xlup).row dim jobduedate string dim jobpn string = 10 lastrow jobduedate = sheet1.range("b" & 10, "b" & i).value (error occurs here) jobpn = sheet1.range("c" & 10, "c" & i).value   if (jobduedate) >= datestart , (jobduedate) <= dateend lbjobsdue.additem (jobpn & "," & cdate(jobduedate)) end if  next end sub   private sub comboxjobsdue_change()  if comboxjobsdue.value = "this week"  startofweek = date - weekday(date) + 2  endofweek = date - weekday(date) + 6 lbljobsdue.caption = (startofweek) & "-" & (endofweek)  call jobsdue((startofweek), (endofweek))  elseif comboxjobsdue.value = "next week" startofweek = date - weekday(date) + 9 endofweek = date - weekday(date) + 13 lbljobsdue.caption = (startofweek) & "-" & (endofweek)  elseif comboxjobsdue.value = "this month" firstdayinmonth = dateserial(year(date), month(date), 1) lastdayinmonth = dateserial(year(date), month(date) + 1, 0) lbljobsdue.caption = firstdayinmonth & "-" & lastdayinmonth  elseif comboxjobsdue.value = "next month" firstdayinmonth = dateserial(year(date), month(date) + 1, 1) lastdayinmonth = dateserial(year(date), month(date) + 2, 0) lbljobsdue.caption = firstdayinmonth & "-" & lastdayinmonth end if end sub 

the error occurs on line 7, when run program debug, jobduedate gets date in format of "9/25/2013", other dates of format 8/18/2014 without quotation marks. can explain me why error happening , how can go fixing it?

thanks in advance, evan

see line declaration reading "dim jobduedate string" (line 4 think) you're telling system want string... perhaps want dim jobduedate date can use date functions on it.

datestart , end being passed in dates error on code calling sub if passed in invalid dates.

additionally, appear attempting assign range of dates date field. either need collection of dates or array of dates handle this.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -