Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Insert/delete rows

Hi again,
I have another problem to solve. The code below is my attempt to stop a
macro from inserting or deleting rows if B9 was included, but for some reason
its not behaving as I thought it would. What am I doing wrong?

If ActiveCell = B9 Then
MsgBox "Please do not select to insert or delete from this row" &
vbNewLine & _
"" & vbNewLine & _
" Please un-select and try again" & vbNewLine & _
" ", , "ERROR"
Exit Sub
End If

Many thanks in advance

John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Insert/delete rows

If Not Intersect(selection,Range("B9")) is Nothing then
MsgBox "Please do not select to insert or delete from this row" &
vbNewLine & _
"" & vbNewLine & _
" Please un-select and try again" & vbNewLine & _
" ", , "ERROR"
Exit Sub
End If

or do you want to guard against any row insertion above or at row 9

If Selection.Row <= 9 then


--
Regards,
Tom Ogilvy


"JohnUK" wrote in message
...
Hi again,
I have another problem to solve. The code below is my attempt to stop a
macro from inserting or deleting rows if B9 was included, but for some

reason
its not behaving as I thought it would. What am I doing wrong?

If ActiveCell = B9 Then
MsgBox "Please do not select to insert or delete from this row" &
vbNewLine & _
"" & vbNewLine & _
" Please un-select and try again" & vbNewLine & _
" ", , "ERROR"
Exit Sub
End If

Many thanks in advance

John



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Insert/delete rows

Your code only gives the message if the ActiveCell is B9 - it sounds like you
want it to run if the selected row includes row 9 regardless if B9 is the
active cell? If I have that right, then this would do it:
If ActiveCell.Row = 9 Then...
--
- K Dales


"JohnUK" wrote:

Hi again,
I have another problem to solve. The code below is my attempt to stop a
macro from inserting or deleting rows if B9 was included, but for some reason
its not behaving as I thought it would. What am I doing wrong?

If ActiveCell = B9 Then
MsgBox "Please do not select to insert or delete from this row" &
vbNewLine & _
"" & vbNewLine & _
" Please un-select and try again" & vbNewLine & _
" ", , "ERROR"
Exit Sub
End If

Many thanks in advance

John

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Insert/delete rows

Tom
Something as simple as that:

If Selection.Row <= 9 then

I need to be shot
Many thanks it works a treat
John
PS and thank you for your help "K"

"Tom Ogilvy" wrote:

If Not Intersect(selection,Range("B9")) is Nothing then
MsgBox "Please do not select to insert or delete from this row" &
vbNewLine & _
"" & vbNewLine & _
" Please un-select and try again" & vbNewLine & _
" ", , "ERROR"
Exit Sub
End If

or do you want to guard against any row insertion above or at row 9

If Selection.Row <= 9 then


--
Regards,
Tom Ogilvy


"JohnUK" wrote in message
...
Hi again,
I have another problem to solve. The code below is my attempt to stop a
macro from inserting or deleting rows if B9 was included, but for some

reason
its not behaving as I thought it would. What am I doing wrong?

If ActiveCell = B9 Then
MsgBox "Please do not select to insert or delete from this row" &
vbNewLine & _
"" & vbNewLine & _
" Please un-select and try again" & vbNewLine & _
" ", , "ERROR"
Exit Sub
End If

Many thanks in advance

John




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
Excel 2007 - Cannot Delete or Insert Rows SCNetworks Excel Discussion (Misc queries) 1 March 24th 09 05:48 PM
IF statements - use to insert/delete rows? WRM Excel Worksheet Functions 5 October 21st 06 08:55 PM
Automatically insert/delete rows to be x apart Mr_Flibble Excel Discussion (Misc queries) 5 February 17th 06 04:04 AM
Macro to insert and delete rows Jonsson Excel Programming 0 January 9th 04 04:53 PM
Macro to insert and delete rows Jonsson Excel Programming 1 January 9th 04 02:28 PM


All times are GMT +1. The time now is 02:59 AM.

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"