Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default Worksheet_Change

I have been trying to use the following code but for some reason Nothing is
happening when I make a change to cell ("A1"). I pasted the code in a module,
and clicked on the sheet1 and right clicked the mouse to view the code and
pasted it in. Can someone tell me what i'm doing wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target = Cells(1, 1) Then Cells(2, 1) = Now
End Sub 'alternatives: NOW() or date or Time

Thanks for any help

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Worksheet_Change

You need to use the Address property to determine what cell was
change. E.g.,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Range("A2").Value = Now
Application.EnableEvents = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ram" wrote in message
...
I have been trying to use the following code but for some reason
Nothing is
happening when I make a change to cell ("A1"). I pasted the
code in a module,
and clicked on the sheet1 and right clicked the mouse to view
the code and
pasted it in. Can someone tell me what i'm doing wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target = Cells(1, 1) Then Cells(2, 1) = Now
End Sub 'alternatives: NOW() or date or Time

Thanks for any help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Worksheet_Change

Don't paste it into a module, right-click onthe sheet tab, and go to
view code, past it there. Works fine for me. GL.

  #4   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default Worksheet_Change

Chip,

I copied in your code and I still have no data in range("A2"). When I first
tried this function early this morning it was working for me. Do you have
any other ideas why this would stop working.
I have tried a veriety of code from the user group, your site and dmcritchie
site none seem to return any data.

Thanks for your help

"Chip Pearson" wrote:

You need to use the Address property to determine what cell was
change. E.g.,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Range("A2").Value = Now
Application.EnableEvents = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ram" wrote in message
...
I have been trying to use the following code but for some reason
Nothing is
happening when I make a change to cell ("A1"). I pasted the
code in a module,
and clicked on the sheet1 and right clicked the mouse to view
the code and
pasted it in. Can someone tell me what i'm doing wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target = Cells(1, 1) Then Cells(2, 1) = Now
End Sub 'alternatives: NOW() or date or Time

Thanks for any help




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Worksheet_Change

It should work. It is possible that events got disabled. In the
Immediate window in VBA (CTRL+g), type the following and then
press Enter.

Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"ram" wrote in message
...
Chip,

I copied in your code and I still have no data in range("A2").
When I first
tried this function early this morning it was working for me.
Do you have
any other ideas why this would stop working.
I have tried a veriety of code from the user group, your site
and dmcritchie
site none seem to return any data.

Thanks for your help

"Chip Pearson" wrote:

You need to use the Address property to determine what cell
was
change. E.g.,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Range("A2").Value = Now
Application.EnableEvents = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ram" wrote in message
...
I have been trying to use the following code but for some
reason
Nothing is
happening when I make a change to cell ("A1"). I pasted the
code in a module,
and clicked on the sheet1 and right clicked the mouse to
view
the code and
pasted it in. Can someone tell me what i'm doing wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target = Cells(1, 1) Then Cells(2, 1) = Now
End Sub 'alternatives: NOW() or date or Time

Thanks for any help








  #6   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default Worksheet_Change

I deleted the module and the steps you have listed. When I change the value
in range("A1") no data is entered into range("A2").

I can't figure out what i'm doing or not doing wrong

"Kevin O'Neill" wrote:

Don't paste it into a module, right-click onthe sheet tab, and go to
view code, past it there. Works fine for me. GL.


  #7   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default Worksheet_Change

Chip,

That was the problem.

Thanks for your time and help

"Chip Pearson" wrote:

It should work. It is possible that events got disabled. In the
Immediate window in VBA (CTRL+g), type the following and then
press Enter.

Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"ram" wrote in message
...
Chip,

I copied in your code and I still have no data in range("A2").
When I first
tried this function early this morning it was working for me.
Do you have
any other ideas why this would stop working.
I have tried a veriety of code from the user group, your site
and dmcritchie
site none seem to return any data.

Thanks for your help

"Chip Pearson" wrote:

You need to use the Address property to determine what cell
was
change. E.g.,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Range("A2").Value = Now
Application.EnableEvents = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ram" wrote in message
...
I have been trying to use the following code but for some
reason
Nothing is
happening when I make a change to cell ("A1"). I pasted the
code in a module,
and clicked on the sheet1 and right clicked the mouse to
view
the code and
pasted it in. Can someone tell me what i'm doing wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target = Cells(1, 1) Then Cells(2, 1) = Now
End Sub 'alternatives: NOW() or date or Time

Thanks for any help







  #8   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default Worksheet_Change

Can you tell me how to write the code if I want the range to be all cells in
column A?

I tried("A:A") and column(1) however neither worked for me
Thanks

"Chip Pearson" wrote:

You need to use the Address property to determine what cell was
change. E.g.,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Range("A2").Value = Now
Application.EnableEvents = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ram" wrote in message
...
I have been trying to use the following code but for some reason
Nothing is
happening when I make a change to cell ("A1"). I pasted the
code in a module,
and clicked on the sheet1 and right clicked the mouse to view
the code and
pasted it in. Can someone tell me what i'm doing wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target = Cells(1, 1) Then Cells(2, 1) = Now
End Sub 'alternatives: NOW() or date or Time

Thanks for any help




  #9   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default Worksheet_Change

I used this code

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
End If
End Sub

"ram" wrote:

Can you tell me how to write the code if I want the range to be all cells in
column A?

I tried("A:A") and column(1) however neither worked for me
Thanks

"Chip Pearson" wrote:

You need to use the Address property to determine what cell was
change. E.g.,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Range("A2").Value = Now
Application.EnableEvents = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ram" wrote in message
...
I have been trying to use the following code but for some reason
Nothing is
happening when I make a change to cell ("A1"). I pasted the
code in a module,
and clicked on the sheet1 and right clicked the mouse to view
the code and
pasted it in. Can someone tell me what i'm doing wrong.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target = Cells(1, 1) Then Cells(2, 1) = Now
End Sub 'alternatives: NOW() or date or Time

Thanks for any help




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
Worksheet_Change Jive Excel Worksheet Functions 2 June 11th 07 10:03 AM
Worksheet_Change scrimmy Excel Discussion (Misc queries) 7 April 26th 07 12:12 PM
Worksheet_Change Greg Bloom Excel Programming 1 November 5th 03 08:44 PM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 05:12 PM.

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

About Us

"It's about Microsoft Excel"