excel vba - Checking cells contain data before printing - Run-Time error -


i've been doing work on spreadsheet work i've, until point, been able solve issues hunting around online. i'm relatively new vba , have built of researching online may pretty rubbish way it. unfortunately i've run problem following code giving me type mismatch error (run-time 13). suspect code pretty self explanatory, i'm trying disable printing in event cells aren't completed. run-time error highlighting bolded section.

private sub workbook_beforeprint(cancel boolean) dim response integer sheets("settlement instruction")     **if .range("m1").value = "" or .range("p1").value = "" _         or .range("e2").value = "" or .range("e3").value = "" or .range("e4").value = "" or .range("m4").value = "" or .range("u3").value = "" _         or (.range("m1").value = "wa" , .range("p1").value = "settlement" , .range("t22").value = "") _         or (.range("p1").value = "outsource" , (.range("c32").value = "" or .range("h37").value = "" or .range("c44").value = "")) _         or (.range("p1").value = "settlement" , (.range("g6").value = "" or .range("f8").value = "" or .range("n8").value = "" or .range("f9").value = "" or .range("c32").value = "" or .range("q35").value = "" or .range("q36").value = "" or .range("h37").value = "" or .range("f41").value = "" or .range("c44").value = "")) _         or (.range("p1").value = "rego only" or "prep only" , (.range("f16").value = "" or .range("f41").value = "" or .range("c44").value = "")) then**         response = msgbox("please complete mandatory fields marked in yellow.", vbok, "information required")         if response = vbok             cancel = true         elseif response = vbcancel             cancel = true          end if     end if end 

prior had following code working (aside of checks being incorrect):

private sub workbook_beforeprint(cancel boolean) dim response integer sheets("settlement instruction")     if (.range("m1").value = "" or .range("e2").value = "" or .range("p1").value = "" or .range("e3").value = "" or .range("e4").value = "" or .range("m4").value = "" or .range("u3").value = "" or .range("c32").value = "" or (.range("p1").value <> "outsource" , .range("f41").value = "" , .range("q35").value = "" , .range("q36").value = "") or .range("c44").value = "" or .range("h37").value = "" or (.range("p1").value = "settlement" , (.range("g6").value = "" or .range("f8").value = "" or .range("n8").value = "" or .range("f9").value = "")) or (.range("p1").value = "settlement" , .range("m1").value = "wa" , .range("t22") = ""))         response = msgbox("please complete mandatory fields marke in yellow.", vbok, "information required")         if response = vbok             cancel = true         elseif response = vbcancel             cancel = true          end if     end if end 

part of change make code easier work instead of on same line, needed make changes checks completed. i'm after 1 thing mainly. able see what's causing run-time error. did check info on microsoft think (been couple of days since looked @ due time constraints) , thing deduce maybe checking values text rather integers. changed formatting 2 integer fields text still had same issue.

any assistance appreciated.

you getting error because of this

.range("p1").value = "rego only" or "prep only"  

you can't use that

change

.range("p1").value = "rego only" or .range("p1").value = "prep only"  

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -