Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
TRB TRB is offline
external usenet poster
 
Posts: 3
Default Possible to trap an 'Insert Row' via VBA ?

So I can apply validation and checks?
TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Possible to trap an 'Insert Row' via VBA ?

Your question is too unclear on what excactly what you want to do. The only
thing which came to my mind is the "Worksheet_Change" event of the worksheet.

However, my opinion is: it could be very difficult to really "trap an insert
row". Difficult to make it efficient and bullet proof. It'll require a
continuous checking of the pre-change and post-change layout of the
worksheet. It could be less difficult if the structure is highly predictable
and restricted.

Regards,
Edwin Tam

http://www.vonixx.com

"TRB" wrote:

So I can apply validation and checks?
TIA

  #3   Report Post  
Posted to microsoft.public.excel.programming
TRB TRB is offline
external usenet poster
 
Posts: 3
Default Possible to trap an 'Insert Row' via VBA ?

Thanks 4 setting me in the right direction, Edwin...
To clarify, if a user doesn't use my form for data entry, but inserts a new
row to edit manually, I wanted to add validation to specific cells. Came up
with the following that seems to work (list validation for cells B1:B10):

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Application.EnableEvents = False
If Target.Column = "2" And Target.Row < 10 Then
With Range(Target.Address).Validation
.Add Type:=xlValidateList, Formula1:=Range("E2")
.ErrorTitle = "Ooops"
.ErrorMessage = "You can do it Bubba - Try Again"
End With
End If
Application.EnableEvents = True
End Sub

"Edwin Tam" wrote:

Your question is too unclear on what excactly what you want to do. The only
thing which came to my mind is the "Worksheet_Change" event of the worksheet.


  #4   Report Post  
Posted to microsoft.public.excel.programming
TRB TRB is offline
external usenet poster
 
Posts: 3
Default Possible to trap an 'Insert Row' via VBA ?

Thanks 4 sending me in the right direction, Edwin! ...

To clarify, I need to provide cell validation if a user doen't use my form
for data input, but inserts a new line and starts editing. Came up with this
that seems to work (list validation for cells B1:B10) :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Application.EnableEvents = False
If Target.Column = "2" And Target.Row < 10 Then
With Range(Target.Address).Validation
.Add Type:=xlValidateList, Formula1:=Range("E2")
.ErrorTitle = "Ooops"
.ErrorMessage = "You can do it Bubba - Try Again"
End With
End If
Application.EnableEvents = True
End Sub

Many thanks, Tom

"Edwin Tam" wrote:

Your question is too unclear on what excactly what you want to do. The only
thing which came to my mind is the "Worksheet_Change" event of the worksheet.

However, my opinion is: it could be very difficult to really "trap an insert
row". Difficult to make it efficient and bullet proof. It'll require a
continuous checking of the pre-change and post-change layout of the
worksheet. It could be less difficult if the structure is highly predictable
and restricted.

Regards,
Edwin Tam

http://www.vonixx.com

"TRB" wrote:

So I can apply validation and checks?
TIA

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
Another 'Copy To The Next Available Row' Question Joe Excel Discussion (Misc queries) 2 March 29th 10 04:25 AM
Permanently link Col A edits, inc 'insert row' in multiple workshe Tchipu Excel Worksheet Functions 2 November 10th 09 02:52 PM
'select table row' dmgrant Excel Discussion (Misc queries) 1 July 18th 09 07:21 AM
Trap Right CLick Insert Von Shean Excel Programming 1 January 22nd 04 04:42 AM
How to get the 'current row' from VBA Peter van de Kerkhof Excel Programming 9 August 2nd 03 09:56 PM


All times are GMT +1. The time now is 08:13 PM.

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

About Us

"It's about Microsoft Excel"