H
Howard
The change event macro is in sheet 1 module.
The TheNameOfMySub macro is in Module 1.
(I had the TheNameOfMySub macro just below the change event in sheet 1 module but it produced an error as if the macro it was calling was not available in this workbook...)
The results are so varied I am at a loss to try to explain them all.
I would appreciate it if you would duplicate a sheet1 and sheet2 with the codes and tell me what I'm doing wrong.
The results I expect are:
If A1:A15 of sheet 1 is changed, then after the time lapses in the change event macro, each cell in A1:A15 will be copied to the first empty cell on sheet 2 of each row.
Seems like first copy works ok, but make a change in A1:A15 and next time there is no copy. The sheet "blinks" like the macro was fired but no results.
If I go to Module 1 and click on the "Run Macro" icon it copies just fine.
There might be some other ghost like stuff that happens sometimes but I've lost track of what they might have been.
Thanks,
Howard
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.OnTime Now + TimeValue("00:00:10"), "TheNameOfMySub"
End Sub
Sub TheNameOfMySub()
Dim c As Range
Application.ScreenUpdating = False
If Not Range("A1:A15") Is Nothing Then
For Each c In Range("A1:A15")
c.Copy
If Sheets("Sheet1").Range("A" & c.Row).Value = "" Then
Sheets("Sheet1").Range("A" & c.Row).PasteSpecial
Else
Sheets("Sheet2").Cells(c.Row, Sheets("Sheet2").Cells(c.Row, Columns.Count). _
End(xlToLeft).Column + 1).PasteSpecial
End If
Next
Else
Exit Sub
End If
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
The TheNameOfMySub macro is in Module 1.
(I had the TheNameOfMySub macro just below the change event in sheet 1 module but it produced an error as if the macro it was calling was not available in this workbook...)
The results are so varied I am at a loss to try to explain them all.
I would appreciate it if you would duplicate a sheet1 and sheet2 with the codes and tell me what I'm doing wrong.
The results I expect are:
If A1:A15 of sheet 1 is changed, then after the time lapses in the change event macro, each cell in A1:A15 will be copied to the first empty cell on sheet 2 of each row.
Seems like first copy works ok, but make a change in A1:A15 and next time there is no copy. The sheet "blinks" like the macro was fired but no results.
If I go to Module 1 and click on the "Run Macro" icon it copies just fine.
There might be some other ghost like stuff that happens sometimes but I've lost track of what they might have been.
Thanks,
Howard
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.OnTime Now + TimeValue("00:00:10"), "TheNameOfMySub"
End Sub
Sub TheNameOfMySub()
Dim c As Range
Application.ScreenUpdating = False
If Not Range("A1:A15") Is Nothing Then
For Each c In Range("A1:A15")
c.Copy
If Sheets("Sheet1").Range("A" & c.Row).Value = "" Then
Sheets("Sheet1").Range("A" & c.Row).PasteSpecial
Else
Sheets("Sheet2").Cells(c.Row, Sheets("Sheet2").Cells(c.Row, Columns.Count). _
End(xlToLeft).Column + 1).PasteSpecial
End If
Next
Else
Exit Sub
End If
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub