compare two values and generate a percentage (excel) -


i trying create spreadsheet keeps track of how many files have been quality checked against haven't , displays amount left checked percentage.

currently on open spreadsheet pulls details checked folder , work checked folder follows:-

private sub pdf_loading()  range("m5").clear  dim folderpath string, path string, count integer folderpath = "c:\path folder\" ' looks in spercific folder path = folderpath & "*.pdf" ' file type time pdf files, though if change word files, or psd's filename = dir(path)  while filename <> "" ' checks filename <less or >greater "filename" "" empty not spercific file     count = count + 1 ' counts amount of pdf files, add 1 last known number     filename = dir() ' contiunes count until reaches end of directory loop   range("m5").value = count ' puts final count value in cell  each cell in [m:m] if cell.value = "0" cell.clearcontents elseif range("m5").value >= 1 end if next cell  end sub 

then checked folder:-

private sub checked_loading()  range("m6").clear  dim folderpath string, path string, count integer folderpath = "c:\path folder\"  path = folderpath & "*.pdf"  filename = dir(path)  while filename <> ""     count = count + 1         filename = dir() loop  range("m6").value = count  each cell in [m:m] if cell.value = "0" cell.clearcontents elseif range("m5").value >= 1 end if next cell  end sub 

this works fine, though formula have tried generate percentage follows:-

=if(m5=m6,"50%",if(m5=0,"100%",if(m6=0,"0%",sum(m5*m6/100*1)))) 

this brings incorrect results 144.00% when files check result 9 , files checked result 16.

i prefer have percentage calculation in vba end users not accidentally delete underlying formula.

any on issue or if there more efficient code structure appreciate.

not worry have found solution works treat. above code looks work checked:-

private sub pdf_loading()  range("k5:l6").clearcontents range("m5").clearcontents ' clear cell contents on open  dim folderpath string, path string, count integer folderpath = "c:\filepath\folder\" ' looks in spercific folder path = folderpath & "*.pdf" ' file type time pdf files, though if change word files, or psd's filename = dir(path)  while filename <> "" ' checks filename <less or >greater "filename" "" empty not spercific file     count = count + 1 ' counts amount of pdf files, add 1 last known number     filename = dir() ' contiunes count until reaches end of directory loop   range("m5").value = count ' puts final count value in cell     end sub 

and work checked folder this:-

private sub checked_loading()  range("m6").clearcontents  dim folderpath string, path string, count integer folderpath = "c:\filepath\folder\"  path = folderpath & "*.pdf"  filename = dir(path)  while filename <> ""     count = count + 1         filename = dir() loop  range("m6").value = count   range("n5").formula = "=sum(m5,m6)" range("k5").formula = "=sum(m6/n5*1)" ' adds formulas selected cells give percentage end sub 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -