Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Simple VBA question

You need to have your code as an event handler.
Go to the code for a sheet (right click a sheet tab).
Then
Private Sub Worksheet_Change( _
ByVal Target As Excel.Range)
Dim x As Integer
MsgBox target.address ' didactic
If Intersect(Target, Range("a1")) Is Nothing Then Exit Sub
x = Range("A1").Value
If x = 1 Then
MsgBox "invalid number in cell A1"
End If
End Sub


Aaron wrote:
Public Sub firsttry()
Dim x As Integer
x = Range("A1").Value
If x = 1 Then
MsgBox "invalid number in cell A1"
End If
End Sub

I have to run the macro for the msgbox to appear. How can it pop up as soon
as the number 1 is entered in cell A1?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple IF question bokey Excel Discussion (Misc queries) 4 May 16th 08 07:04 PM
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
simple question, hopefully a simple answer! Matt B Excel Programming 5 January 13th 04 08:43 PM
a simple question David Price[_2_] Excel Programming 0 September 1st 03 02:13 PM


All times are GMT +1. The time now is 09:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"