Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Using Workbook_SheetChange for single column

What is the simplest way to use the "Private Sub Workbook_SheetChange(ByVal
Sh As Object, ByVal Target As Range)" for only one column? Or maybe this
isn't the choice I want to use. I want to run a macro only if data has been
added to a cell in column "C".
Any help would be appreciated.
Thanks in advance,
Brad K

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Using Workbook_SheetChange for single column

Try this:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sh.Name = "Sheet1" Then
If Not Intersect(Target, Columns("C")) Is Nothing Then
Beep
End If
End If
End Sub


Be aware that each Worksheet has it's own events for handling Change
So instead of receiving the Workbook event and working out which sheet it's
for, you could just receive the Worksheet event.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Brad K." wrote in message
...
What is the simplest way to use the "Private Sub
Workbook_SheetChange(ByVal
Sh As Object, ByVal Target As Range)" for only one column? Or maybe this
isn't the choice I want to use. I want to run a macro only if data has
been
added to a cell in column "C".
Any help would be appreciated.
Thanks in advance,
Brad K



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Using Workbook_SheetChange for single column

If you want to trigger this event for changes in col C of ALL sheets then use
the Workbook_SheetChange event .

If you want to trigger this event for changes in col C of JUST CERTAIN
sheets then use the Worksheet_Change event .

Here's the code:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count1 then Exit Sub
If Not Intersect(Target, Range("C:C")) Is Nothing Then
Application.EnableEvents=False 'this prevents continuous looping
'''' Call your macro - placed in a Standard module
'''' or add your code directly here
End If
Application.EnableEvents=True 'This is required, unlike ScreenUpdating
End Sub
"Brad K." wrote:

What is the simplest way to use the "Private Sub Workbook_SheetChange(ByVal
Sh As Object, ByVal Target As Range)" for only one column? Or maybe this
isn't the choice I want to use. I want to run a macro only if data has been
added to a cell in column "C".
Any help would be appreciated.
Thanks in advance,
Brad K

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
From single cell variables to a single column serie noyau New Users to Excel 1 December 22nd 06 06:43 AM
Return Single Row of Numeric Data to Single Column Sam via OfficeKB.com Excel Worksheet Functions 4 December 17th 05 12:31 AM
Workbook_sheetChange event J S Excel Programming 0 August 9th 04 07:16 PM
workbook_sheetchange JulieD Excel Programming 1 June 14th 04 04:32 AM
Workbook_SheetChange will not fire Robert Willard Excel Programming 1 September 10th 03 07:52 PM


All times are GMT +1. The time now is 03:20 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"