Excel VBA Type Mismatch Error 13 -


i'm kind of new vba, , having problems working multiple workbooks @ once. had code functional takes data 1 sheet given conditions met.

now trying update code move 1 workbook another, , have begun declare workbooks instead of referencing sheet names.

now getting various errors.

code follows.

before (worked)

option explicit sub trenddatabyday()     'determine date of data pulled     dim currentdate string      currentdate = sheets("daily pull").range("b23").value 

after (fails; using 2 workbooks)

option explicit sub trenddatabyday()     dim wbdaily, wbhistory workbook      'declare daily , history workbooks     set wbdaily = activeworkbook     workbooks.open filename:="\\daily focus metrics\focus metrics history facility.xlsm"     set wbhistory = application.workbooks("focus metrics history facility.xlsm")      'determine date of data pulled     dim currentdate string      'error here!     currentdate = workbooks(wbdaily).sheets("daily pull").range("b23").value 

i tried:

currentdate = wbdaily.sheets("daily pull").range("b23").value 

i need understand why cannot declare these workbooks , specify workbook sheet belongs in way. know ideal way reference , dim workbooks without having "select" each workbook when copying or pasting data.

change workbooks(wbdaily) wbdaily

also small note .. unlike vb.net

dim wbdaily, wbhistory workbook 

is same

dim wbdaily variant dim wbhistory workbook 

so can change

dim wbdaily workbook, wbhistory workbook 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -