ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet_Change (https://www.excelbanter.com/excel-programming/349645-worksheet_change.html)

Ram

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


Chip Pearson

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




Kevin O'Neill[_2_]

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.


Ram

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





Chip Pearson

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







Ram

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.



Ram

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








Ram

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





Ram

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






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

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