Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 334
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 334
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
RTD feeds into excel not trigering a worksheet change macro DTM[_4_] Excel Programming 1 June 8th 06 07:09 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 04:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"