excel - Numberformat that allows me to enter formulas but stores values as text? -


is possible set numberformat in cell/column using either excel or vba that:

  • if enter formula (anything starting =) excel calculate formula (and not interpret text)
  • if enter value, example 5.80, excel store text?

i'm having problem want user input stored text, users should able enter formulas. if set numberformat text, formulas aren't interpreted. if set numberformat general, values stored numbers.

here version.

format cells in sheet text. code uses application.evaluate() evaluate formulas , store result text.

private sub worksheet_change(byval target range)     dim acell range      on error goto whoa      application.enableevents = false      '~~> need in case user copies formula     '~~> sheet     target.cells.numberformat = "@"      '~~> looping though cells in case user     '~~> copies formula sheet     each acell in target.cells         if left(acell.formula, 1) = "=" _         acell.value = application.evaluate(acell.formula)     next  letscontinue:     application.enableevents = true     exit sub whoa:     msgbox err.description     resume letscontinue end sub 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -