Display Message with Macro in Spreadsheet

April 21, 2009 by vba excel
Filed under: Excel Spreadsheet, Excel Vba 
Sponsor

Excel Vba Display Message with Macro in Spreadsheet [Q]

I have to create microsoft excel spreadsheet with a range of cells with excel formula. I would like to create display of message in excel spreadsheet

” This cell contains excel formulas. Please do not type here”

when a user clicks on a range of cells with excel formula.

Excel Vba Display Message with Macro in Spreadsheet [A]

I think using excel worksheet protection is much easier and safer (excel macros setting can be disabled).

But if you want:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim FormulaCells As Range

Set FormulaCells = Nothing
On Error Resume Next
Application.EnableEvents = False
Set FormulaCells = Intersect(Target, _
Target.Cells.SpecialCells(xlCellTypeFormulas), _
Me.UsedRange)
Application.EnableEvents = True
On Error GoTo 0

If FormulaCells Is Nothing Then
‘ok
Else
MsgBox “Your selection contains formulas”
Application.EnableEvents = False
Application.Goto Me.Range(”a1″)
Application.EnableEvents = True
End If

End Sub

If you want to try, rightclick on the excel worksheet tab that should have this behavior. Select view code. Paste this into the newly opened code window. I went back to A1. You should change that to where you want them to be if they selected a range with at least one cell with a excel formula.

Then back to microsoft excel to test it out.

Ps. Lots of things get disabled when you run excel vba macros. Try the undo or redo
buttons.

  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Live
  • MisterWong
  • Propeller
  • StumbleUpon
  • Technorati
  • TwitThis
  • YahooMyWeb
  • Print this article!

Rate This Tips:

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Incoming excel search terms

macro in spreadsheet,vba display message,excel macro display a message,excel macro error message,excel vba display message,how to display message with time delay in excel,display message macro,excel display message,excel macro not show error messages,macro how to display a message on error,macro to display a range of cells in message box,msg excel,assign a macro to display a message,cell displays macro,code to copy worksheet and disable macro,conditional error message excel,copy worksheet messagebox vba,creating a loading message for excel macro,disable error msg excel workbook,disable error popups excel vba,disable excel macros message,display cells in macro in excel,display error macro,display error message macro,display error message when macros disabled,display error messages from a macro excel,display error messages from excel macro,display macro in excel,display macro on spreadsheet,display macro spreadsheet,display many cells in one message in a macro in vb,display message box in excel,display message entire worksheet,display message for 1 second excel,display message on opening a worksheet macro,display message on worksheet change excel,display message when macro disabled,display message when opening excel,display multiple message in excel by vba,display multiple messages vba,display numbers on worksheet vba,displaying excel spreadsheets,displaying message excel worksheet,displaying multiple message boxes in excel,ecel spreadsheet vba target rows,email multiple rows excel macro,error message excel macro,error message macro excel,excel,excel change cells in macro when a new row is inserted



Related Excel Tips

Comments

Have another excel answer or questions for this problem ?
Feel free to post it here..