How do I get a range of cells with an Excel VBA function to calculate individually and not all display the same value?

I've written a function in VBA that looks at the contents of certain nearby cells and then returns a string based on their values. I want this function to run on a whole column of cells. However, when I fill down, every single cell displays the same value, that of whichever cell I edited and pressed enter for. I've tried setting `Application.Volatile` as well as recalculating the sheet (both using `F9` and `ActiveSheet.Calculate`) but none of those have worked. I also tried setting `ActiveCell.Value` to be the string I want returned, and then not returning anything from the function, but excel says this is a circular reference. Any suggestions? Here's (the relevant parts of) my code: Function foginSpeechP() Application.Volatile True ActiveSheet.Calculate '..... If scenario = "SR-1A" Then first = "nofog" secnd = "fog" ElseIf scenario = "SR-1B" Then first = "fog" secnd = "nofog" Else: foginSpeechP = "NOT A REAL SCENARIO in foginSpeechP" End If If (IsNumeric(ActiveCell.Offset(0, 4)) And ActiveCell.Offset(0, 4) > 0) Then currTimeStamp = ActiveCell.Offset(0, 4) Else: foginSpeechP = "NO TIME STAMP IN FOGINSPEECHP()" End If If currTimeStamp

以上就是How do I get a range of cells with an Excel VBA function to calculate individually and not all display the same value?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » excel

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏