arrays - VBA function to tell machine not to display certain variables -


i wondering if there way tell excel not display variables if vlookup function couldn't find anything.

here's code does: take numbers in excel workbook looking them up, compare value previous year , take difference, display difference in spreadsheet, in 1 big merged cell. excerpts code:

casho = val(application.vlookup("cash" & "*", workbooks("creditreport.csv").activesheet.range("a1:f199"), 4, false)) 

then difference cash = round(cashn - casho, 0)

then display: mergedcell.value = "cash increased by" & cash

but dont want display cash if couldnt find cash in first place (if case, cash = 0 both when cash couldnt found , when change null).

i thinking of creating array variables (cash, ...) , loop through it. couldn't find online on "if not found dont display anything".

best,

you can use if else statement check value of cash , write value if cash has value , other message "no change" or "no previous value" if that's case.

if cash = 0     mergedcell.value = "no change" else     mergedcell.value = "cash increased by" & cash end if 

Comments