Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
.

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
Macro to select files and then run different macro on selected file [email protected] Excel Programming 5 January 31st 08 03:39 AM
Run macro when cell is selected Corey Excel Programming 7 October 29th 07 04:15 AM
run macro when cell is selected beauty_bobaloo Excel Worksheet Functions 9 January 30th 06 11:11 PM
Macro to take selected cells times a selected cell Craig Excel Programming 4 October 24th 05 12:54 AM
Macro to run in same row as selected button nejl Excel Programming 2 September 6th 04 02:17 PM


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