ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Show one of multiple comment boxes based on value (https://www.excelbanter.com/excel-programming/359955-show-one-multiple-comment-boxes-based-value.html)

kurtech

Show one of multiple comment boxes based on value
 
I have a worksheet that includes multiple comment boxes and have come across
something I need help with.

If the value in a1 15 then show a warning "value is greater than 15"
If the valude in a1 < 15 then show "acceptable value"

I'm a newbie at VB and Script Editor so details would be most appreciated!!

[email protected]

Show one of multiple comment boxes based on value
 
Hi
What about a1 = 15?
Seems a lot of trouble to put this in a cell comment, if that is what
you mean. In a second column you could put the formula
=if(a1<15,"acceptable value","value is greater than or equal to 15")

or you could use conditional formatting, with condition a1<15 to colour
acceptable values.

No need for macros with either of these approaches.

regards
Paul


Tom Ogilvy

Show one of multiple comment boxes based on value
 
right click on the worksheet tab and select view code.

then choose the Calculate event.

Private Sub Worksheet_Calculate()
if Range("A1").Value 15 then
Range("A1").NoteText Text:="value is greater than 15"
else
Range("A1").NoteText Text:="acceptable value"
end if
End Sub

If the cell will be altered by editing it, then perhaps you want to use
Data=Validation which does not require a macro, but can be overwritten by
pasting into the cell.

--
Regards,
Tom Ogilvy


" wrote:

Hi
What about a1 = 15?
Seems a lot of trouble to put this in a cell comment, if that is what
you mean. In a second column you could put the formula
=if(a1<15,"acceptable value","value is greater than or equal to 15")

or you could use conditional formatting, with condition a1<15 to colour
acceptable values.

No need for macros with either of these approaches.

regards
Paul



kurtech

Show one of multiple comment boxes based on value
 
Thanks for the response. I thought about that, but this is going to be a
document used by multiple people, and the purpose of the comment box is to
play a role of a "warning" are you sure you want to use that value...any
ideas?

wrote:
Hi
What about a1 = 15?
Seems a lot of trouble to put this in a cell comment, if that is what
you mean. In a second column you could put the formula
=if(a1<15,"acceptable value","value is greater than or equal to 15")

or you could use conditional formatting, with condition a1<15 to colour
acceptable values.

No need for macros with either of these approaches.

regards
Paul


kurtech

Show one of multiple comment boxes based on value
 
I never thought about validation. That should work perfectly..thanks for your
help!!

Tom Ogilvy wrote:
right click on the worksheet tab and select view code.

then choose the Calculate event.

Private Sub Worksheet_Calculate()
if Range("A1").Value 15 then
Range("A1").NoteText Text:="value is greater than 15"
else
Range("A1").NoteText Text:="acceptable value"
end if
End Sub

If the cell will be altered by editing it, then perhaps you want to use
Data=Validation which does not require a macro, but can be overwritten by
pasting into the cell.

Hi
What about a1 = 15?

[quoted text clipped - 9 lines]
regards
Paul



All times are GMT +1. The time now is 02:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com