ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Not to run macro if row 1 selected (https://www.excelbanter.com/excel-programming/436800-not-run-macro-if-row-1-selected.html)

joek

Not to run macro if row 1 selected
 
I need to run a macro to delete a row if any cell in that row is selected.
However I do not want the macro to run if row 1 is selected.

Seems simple but I can't get my head around it using IF THEN.

I would be grateful for any help

Don Guillett

Not to run macro if row 1 selected
 

As ALWAYS, post your code for comments
if activecell.row=1 then exit sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Joek" wrote in message
...
I need to run a macro to delete a row if any cell in that row is selected.
However I do not want the macro to run if row 1 is selected.

Seems simple but I can't get my head around it using IF THEN.

I would be grateful for any help



Barb Reinhardt

Not to run macro if row 1 selected
 
How about something like this

If Selection.Row = 1 And _
Selection.Rows.Count = 1 Then Exit Sub

--
HTH,

Barb Reinhardt



"Joek" wrote:

I need to run a macro to delete a row if any cell in that row is selected.
However I do not want the macro to run if row 1 is selected.

Seems simple but I can't get my head around it using IF THEN.

I would be grateful for any help


Dave Peterson

Not to run macro if row 1 selected
 
with activesheet
If intersect(selection, .rows(1)) is nothing then
'do the work
else
msgbox "don't touch row 1!"
end if
end with

Joek wrote:

I need to run a macro to delete a row if any cell in that row is selected.
However I do not want the macro to run if row 1 is selected.

Seems simple but I can't get my head around it using IF THEN.

I would be grateful for any help


--

Dave Peterson

joek

Not to run macro if row 1 selected
 
Thanks for the prompt reply Barb

your solution was most helpful

Joe

"Barb Reinhardt" wrote:

How about something like this

If Selection.Row = 1 And _
Selection.Rows.Count = 1 Then Exit Sub

--
HTH,

Barb Reinhardt



"Joek" wrote:

I need to run a macro to delete a row if any cell in that row is selected.
However I do not want the macro to run if row 1 is selected.

Seems simple but I can't get my head around it using IF THEN.

I would be grateful for any help


joek

Not to run macro if row 1 selected
 

Thanks Don - a very simple solution.

I was working at something similar but the macro always hung at this point.

Thank you very much

Joe


"Don Guillett" wrote:


As ALWAYS, post your code for comments
if activecell.row=1 then exit sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Joek" wrote in message
...
I need to run a macro to delete a row if any cell in that row is selected.
However I do not want the macro to run if row 1 is selected.

Seems simple but I can't get my head around it using IF THEN.

I would be grateful for any help


.


joek

Not to run macro if row 1 selected
 
Thanks Dave

As with all these solutions - very simple and straightforward.

Thanks

Joe

"Dave Peterson" wrote:

with activesheet
If intersect(selection, .rows(1)) is nothing then
'do the work
else
msgbox "don't touch row 1!"
end if
end with

Joek wrote:

I need to run a macro to delete a row if any cell in that row is selected.
However I do not want the macro to run if row 1 is selected.

Seems simple but I can't get my head around it using IF THEN.

I would be grateful for any help


--

Dave Peterson
.



All times are GMT +1. The time now is 10:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com