VBA (highlight Hardcode cell (i.e.1234) in Excel) after model is built

一曲冷凌霜 提交于 2019-12-13 08:49:38

问题


I'm building a financial model and i'm trying to highlight all the cells after the model is complete. I need to identify which one are hardcoded after the model is completely without searching for each input one by one.

it would be great, If you can help with a vba for the whole excel tab and a selected range on a sheet. thank you.


回答1:


I believe what you are asking is to look through a range, and then highlight any values within that range that don't contain a formula. So first find the range you want to highlight and then find the ranges within that range that contain a formula. For my example we'll say that your model is from cells A1 to A100

Public Sub hightlightNoFormulas()
     Dim yourRange as Range, rangeNoFormula as Range
     Set yourRange = Range("A1:A100")
     Set rangeNoFormula = yourRange.SpecialCells xlCellTypeFormulas

Then loop through your range, excluding any values that have formulas

     Dim rng as Range
     For Each rng in yourRange
          If Intersect(rng,rangeNoFormula) Is Nothing Then
               rng.interior.Color = 65535
          End If
     Next rng
Exit Sub


来源:https://stackoverflow.com/questions/21388721/vba-highlight-hardcode-cell-i-e-1234-in-excel-after-model-is-built

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!