Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Worksheet_Change | Excel Worksheet Functions | |||
Worksheet_Change | Excel Discussion (Misc queries) | |||
Worksheet_Change | Excel Programming | |||
worksheet_change vs. calculate, and worksheet_change not running | Excel Programming | |||
worksheet_change vs. calculate, and worksheet_change not running | Excel Programming |