Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
168 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...