Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Trying to test several columns for changes when entering data

I have tried the code below, but it does not seem to work. Some times I get
a type mismatch on the first "IF" statement, then other times it will show
the first two msgbox.
What I am trying to do is to test for different column changes, and then
based on what column, run an event.
example. For column A, I want to copy code from another WS,
Column BD, the set the formating of the cell after a PASTE
There are about 6 columns I need to check.

Thanks
Bruce



Private Sub worksheet_change(ByVal rngTarget As Range)

If Intersect(Range("A:A, C:C, F:F, BD:bd"), rngTarget) Then
Application.EnableEvents = False
irow = ActiveCell.Row
temp = MsgBox(irow)
icolumn = ActiveCell.Column
temp = MsgBox(icolumn)

Select Case Cells(rngTarget.Column, 2).Value
Case 1
MsgBox "columnA"
Case 3
MsgBox "test"
Case 6
MsgBox "testf"
Case 57
MsgBox "Column BD"

Case Else
End Select
Else
'do nothing - the cell we need to watch hasn't been changed
End If
Application.EnableEvents = True

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Trying to test several columns for changes when entering data

I would guess that

Cells(rngTarget.Column, 2).Value

should be

Cells(2,rngTarget.Column).Value

and for the first IF statement

If Intersect(Range("A:A, C:C, F:F, BD:bd"), rngTarget) Then

should be

If Not Intersect(Range("A:A, C:C, F:F, BD:bd"), rngTarget) is nothing Then


--
Regards,
Tom Ogilvy

"Bruce" wrote:

I have tried the code below, but it does not seem to work. Some times I get
a type mismatch on the first "IF" statement, then other times it will show
the first two msgbox.
What I am trying to do is to test for different column changes, and then
based on what column, run an event.
example. For column A, I want to copy code from another WS,
Column BD, the set the formating of the cell after a PASTE
There are about 6 columns I need to check.

Thanks
Bruce



Private Sub worksheet_change(ByVal rngTarget As Range)

If Intersect(Range("A:A, C:C, F:F, BD:bd"), rngTarget) Then
Application.EnableEvents = False
irow = ActiveCell.Row
temp = MsgBox(irow)
icolumn = ActiveCell.Column
temp = MsgBox(icolumn)

Select Case Cells(rngTarget.Column, 2).Value
Case 1
MsgBox "columnA"
Case 3
MsgBox "test"
Case 6
MsgBox "testf"
Case 57
MsgBox "Column BD"

Case Else
End Select
Else
'do nothing - the cell we need to watch hasn't been changed
End If
Application.EnableEvents = True

End Sub


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
problem with test to columns feature identifying odd delimiting character mark_jm via OfficeKB.com Excel Discussion (Misc queries) 4 May 4th 10 11:22 AM
test data in two columns, return totals eugene Excel Worksheet Functions 3 February 22nd 08 06:05 AM
TEST for items in 2 columns to MATCH? nastech Excel Discussion (Misc queries) 4 September 22nd 07 05:29 AM
Entering subtotals quickly in several columns quartz[_2_] Excel Programming 2 October 13th 05 03:13 PM
Sum one column after capmaring test from teo more columns Ashfaq Excel Worksheet Functions 1 January 5th 05 02:45 PM


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