Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
trigering macro
How do I triger a macro to run when I exit cell "C1"
Macro is to copy "A1:C1" to another sheet in a different book This is to be repeated each time I exit column "C_", row after row. Thanks, Rick |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
trigering macro
Hi Rick -
Add this code to the worksheet's module. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ActiveCell.Column = 4 Or ActiveCell.Column = 2 Then MsgBox "Exited Column C..." 'replace this line with a call to your other macro End If End Sub -- Jay "Rick" wrote: How do I triger a macro to run when I exit cell "C1" Macro is to copy "A1:C1" to another sheet in a different book This is to be repeated each time I exit column "C_", row after row. Thanks, Rick |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
trigering macro
Sorry Jay:
After entering data in col "A1", the msg execiting column "C" appeared. Rick "Jay" wrote: Hi Rick - Add this code to the worksheet's module. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ActiveCell.Column = 4 Or ActiveCell.Column = 2 Then MsgBox "Exited Column C..." 'replace this line with a call to your other macro End If End Sub -- Jay "Rick" wrote: How do I triger a macro to run when I exit cell "C1" Macro is to copy "A1:C1" to another sheet in a different book This is to be repeated each time I exit column "C_", row after row. Thanks, Rick |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
trigering macro
Rick -
Delete previous code and add all of the code below to the worksheet's module. Let me know how it works; we'll modify it if we have to... Note 1. Change the terms "YourDesinationWorkBookName.xls" to the actual name of your desination workbook. Note 2. Change the terms "YourSheetName" to the actual name of your desination worksheet. Note 3. Both the source workbook and the destination workbook must be open. --------------------------------------------------------------------------------------------- Public startCol As Integer Public startRow As Long Private Sub Worksheet_Activate() startCol = ActiveCell.Column End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim wb1 As Workbook Dim wb2 As Workbook Dim ws1 As Worksheet Dim ws2 As Worksheet Application.ScreenUpdating = False On Error GoTo errorHandler Set wb1 = ActiveWorkbook Set ws1 = ActiveSheet If (ActiveCell.Column < 3 And startCol = 3) Or _ (ActiveCell.Column < 3 And startCol = 3) Then Set wb2 = Workbooks("YourDestinationWorkBookName.xls") Set ws2 = wb2.Worksheets("YourSheetName") rw = startRow Range(Cells(rw, 1), Cells(rw, 3)).Copy wb2.Activate ws2.Range("A" & ws2.Rows.Count).End(xlUp).Offset(1, 0).Activate ws2.Paste End If ws1.Activate Application.CutCopyMode = False Application.ScreenUpdating = True startCol = ActiveCell.Column startRow = ActiveCell.Row Exit Sub errorHandler: MsgBox "The destination workbook must be open..." End Sub -- Jay "Rick" wrote: Sorry Jay: After entering data in col "A1", the msg execiting column "C" appeared. Rick "Jay" wrote: Hi Rick - Add this code to the worksheet's module. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ActiveCell.Column = 4 Or ActiveCell.Column = 2 Then MsgBox "Exited Column C..." 'replace this line with a call to your other macro End If End Sub -- Jay "Rick" wrote: How do I triger a macro to run when I exit cell "C1" Macro is to copy "A1:C1" to another sheet in a different book This is to be repeated each time I exit column "C_", row after row. Thanks, Rick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
Need syntax for RUNning a Word macro with an argument, called from an Excel macro | Excel Programming | |||
RTD feeds into excel not trigering a worksheet change macro | Excel Programming | |||
how to count/sum by function/macro to get the number of record to do copy/paste in macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |