Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"AfterPaste" event
I'm copying data from another program to excel 97. I need
a macro that run directly after i've pasted the data. The WorkSheetChange event doesn't work. Can someone help me please?? Thanks Lars Kofod |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
"AfterPaste" event
Lars,
I checked for manual and VBA paste functions - the Worksheet_Change event "should" work. Can you verify if you have set Application.EnableEvents = False before the paste action? Alex J "Lars Kofod" wrote in message ... I'm copying data from another program to excel 97. I need a macro that run directly after i've pasted the data. The WorkSheetChange event doesn't work. Can someone help me please?? Thanks Lars Kofod |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
"AfterPaste" event
The worksheetchange event does work when I paste from
excel, but not from the program I need to paste from. Application.EnabelEvents should that be true or false? I haven't set it to either. Thank you Alex J. Lars Kofod Denmark -----Original Message----- Lars, I checked for manual and VBA paste functions - the Worksheet_Change event "should" work. Can you verify if you have set Application.EnableEvents = False before the paste action? Alex J "Lars Kofod" wrote in message ... I'm copying data from another program to excel 97. I need a macro that run directly after i've pasted the data. The WorkSheetChange event doesn't work. Can someone help me please?? Thanks Lars Kofod . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
"AfterPaste" event
Lars,
Application.EnableEvents should be true, otherwise events (such as changes) are ignored. If you have not been setting it to "off" in VBA to achieve certain results, then that probably is not the source of your problem. (It is reset when the Excel is restarted). How about this: In order to have the macro run after the other program (what is it, by the way?) pastes to the Excel sheet, the following options seem logical: 1. Have the external application launch an Excel macro 2. Try to "fake" the event, or infer it 3. Have a button available for the user to manually kick off the macro. I'll assume that 1 and 3 are yours As far as 'faking' the event, two ideas come to mind: 1. Use the WorkSheet_SelectionChange Event to verify if new data has arrived (try it) 2, Use the calculate event in the same way. In order to detect if data has changed on the sheet, would it be reasonable to assume that the sheet was previously (mostly) blank, and new pasted data drastically increases the size of the used range? Why not try this program on the Sheet Object: Sub test() Static n1 As Long Dim nn As Long nn = Application.WorksheetFunction.Subtotal(3, Me.UsedRange) If nn < n1 Then Msgbox "Found a Change" n1 = nn End If End Sub n1 is static, it holds its value between execution cycles of the program The function is pretty fast Instead of using "3" in the subtotal to count cells, try "9" to sum cell values? Hope this points in a creative direction for you. Alex J "Lars Kofod" wrote in message ... The worksheetchange event does work when I paste from excel, but not from the program I need to paste from. Application.EnabelEvents should that be true or false? I haven't set it to either. Thank you Alex J. Lars Kofod Denmark -----Original Message----- Lars, I checked for manual and VBA paste functions - the Worksheet_Change event "should" work. Can you verify if you have set Application.EnableEvents = False before the paste action? Alex J "Lars Kofod" wrote in message ... I'm copying data from another program to excel 97. I need a macro that run directly after i've pasted the data. The WorkSheetChange event doesn't work. Can someone help me please?? Thanks Lars Kofod . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
"AfterPaste" event
Sorry Lars,
I meant to say that the small routine I called Test should in fact sun under the WorkSheet_Calculate event. That way is will check regularly for a change Alex J "Alex J" wrote in message ... Lars, Application.EnableEvents should be true, otherwise events (such as changes) are ignored. If you have not been setting it to "off" in VBA to achieve certain results, then that probably is not the source of your problem. (It is reset when the Excel is restarted). How about this: In order to have the macro run after the other program (what is it, by the way?) pastes to the Excel sheet, the following options seem logical: 1. Have the external application launch an Excel macro 2. Try to "fake" the event, or infer it 3. Have a button available for the user to manually kick off the macro. I'll assume that 1 and 3 are yours As far as 'faking' the event, two ideas come to mind: 1. Use the WorkSheet_SelectionChange Event to verify if new data has arrived (try it) 2, Use the calculate event in the same way. In order to detect if data has changed on the sheet, would it be reasonable to assume that the sheet was previously (mostly) blank, and new pasted data drastically increases the size of the used range? Why not try this program on the Sheet Object: Sub test() Static n1 As Long Dim nn As Long nn = Application.WorksheetFunction.Subtotal(3, Me.UsedRange) If nn < n1 Then Msgbox "Found a Change" n1 = nn End If End Sub n1 is static, it holds its value between execution cycles of the program The function is pretty fast Instead of using "3" in the subtotal to count cells, try "9" to sum cell values? Hope this points in a creative direction for you. Alex J "Lars Kofod" wrote in message ... The worksheetchange event does work when I paste from excel, but not from the program I need to paste from. Application.EnabelEvents should that be true or false? I haven't set it to either. Thank you Alex J. Lars Kofod Denmark -----Original Message----- Lars, I checked for manual and VBA paste functions - the Worksheet_Change event "should" work. Can you verify if you have set Application.EnableEvents = False before the paste action? Alex J "Lars Kofod" wrote in message ... I'm copying data from another program to excel 97. I need a macro that run directly after i've pasted the data. The WorkSheetChange event doesn't work. Can someone help me please?? Thanks Lars Kofod . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
automatically updating "school event record" formula | Excel Worksheet Functions |