Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Detect if current select is a row
Is it possible to test to see if the current selection is a row? I have a
command button that is designed to delete the selected row but but I need to test to see if it is selected before running the rest of the macro. Thank you. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Detect if current select is a row
Use Selection.Address to check
If row 17 is selected this will return $17:$17 -- If this post helps click Yes --------------- Jacob Skaria "Billy B" wrote: Is it possible to test to see if the current selection is a row? I have a command button that is designed to delete the selected row but but I need to test to see if it is selected before running the rest of the macro. Thank you. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Detect if current select is a row
Why test if the entire row is selected when you can force the selection of
the entire row; something like this... ' Ask user to select the row as you do now, then run this code If Selection.Columns = 1 Then Selection.EntireRow.Select ' ' the rest of your code goes here ' Else MsgBox "You selected more than one row!" End If Although I'm willing to bet that you don't really need to perform the selection operation as opposed to simply working with the range itself in code. -- Rick (MVP - Excel) "Billy B" wrote in message ... Is it possible to test to see if the current selection is a row? I have a command button that is designed to delete the selected row but but I need to test to see if it is selected before running the rest of the macro. Thank you. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Detect if current select is a row
If you are looking to delete the row you can use
Rows(Selection.row).delete -- If this post helps click Yes --------------- Jacob Skaria "Jacob Skaria" wrote: Use Selection.Address to check If row 17 is selected this will return $17:$17 -- If this post helps click Yes --------------- Jacob Skaria "Billy B" wrote: Is it possible to test to see if the current selection is a row? I have a command button that is designed to delete the selected row but but I need to test to see if it is selected before running the rest of the macro. Thank you. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Detect if current select is a row
Thank you for the help. What is really going on is the user may or may not
select the row and if the row is selected, do the procedure and if only a cell is selected, select the row. The next reply did address that. Thanks again. "Jacob Skaria" wrote: If you are looking to delete the row you can use Rows(Selection.row).delete -- If this post helps click Yes --------------- Jacob Skaria "Jacob Skaria" wrote: Use Selection.Address to check If row 17 is selected this will return $17:$17 -- If this post helps click Yes --------------- Jacob Skaria "Billy B" wrote: Is it possible to test to see if the current selection is a row? I have a command button that is designed to delete the selected row but but I need to test to see if it is selected before running the rest of the macro. Thank you. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Detect if current select is a row
Other options, customize depending on how much control you want to have, or
to what degree you want to flex based on the user selection. ' To accept the top left cell as the starting point, but expand to the entire row. One row max. Selection.Cells(1,1).EntireRow.Delete ' To allow multiple rows to be deleted at one time Selection.EntireRow.Delete ' To force the user to re-select With Selection If .Rows.Count 1 Or .Columns.Count < Columns.Count Then MsgBox "Select one row to delete from." Else .EntireRow.Delete End If End With -- Regards, Tim Zych http://www.higherdata.com Workbook Compare - Excel data comparison utility "Billy B" wrote in message ... Is it possible to test to see if the current selection is a row? I have a command button that is designed to delete the selected row but but I need to test to see if it is selected before running the rest of the macro. Thank you. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Detect if current select is a row
If Selection.Columns = 1 Then
Of course the above should have been... If Selection.Rows = 1 Then -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... Why test if the entire row is selected when you can force the selection of the entire row; something like this... ' Ask user to select the row as you do now, then run this code If Selection.Columns = 1 Then Selection.EntireRow.Select ' ' the rest of your code goes here ' Else MsgBox "You selected more than one row!" End If Although I'm willing to bet that you don't really need to perform the selection operation as opposed to simply working with the range itself in code. -- Rick (MVP - Excel) "Billy B" wrote in message ... Is it possible to test to see if the current selection is a row? I have a command button that is designed to delete the selected row but but I need to test to see if it is selected before running the rest of the macro. Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to select current sheet tab | Excel Programming | |||
Select Current Row | Excel Programming | |||
How do I detect and commit the current cell edition? | Excel Programming | |||
how to select current range | Excel Programming | |||
How to detect current active sheet number | Excel Programming |