Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How do I check the number of rows selected

Hi,

My sheet has about 30 rows. I want the user to select only one row and
that row gets copied to a new sheet.

The Code to let the user select the row is

Set rng = Application.InputBox(prompt:="Select Column to Work on",
Type:=8)
rng.Select

How do I make sure the sure only one row is selected?

If more than one row is selected I need to display an error message.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default How do I check the number of rows selected

something like this

Sub test()
If Selection.Rows.Count 1 Then
MsgBox "please select only 1 row"
Else
'your code
End If

End Sub

--


Gary


"NickHK" wrote in message
...
If rng.Rows.count 1 then
MsgbOx "Single row only"
...etc

However, you Input Prompt is somewhat confusing. Instead of "Select Column
to Work on", use "Select a single row".

NickHK

wrote in message
oups.com...
Hi,

My sheet has about 30 rows. I want the user to select only one row and
that row gets copied to a new sheet.

The Code to let the user select the row is

Set rng = Application.InputBox(prompt:="Select Column to Work on",
Type:=8)
rng.Select

How do I make sure the sure only one row is selected?

If more than one row is selected I need to display an error message.

Thanks





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How do I check the number of rows selected

If rng.Rows.count 1 then
MsgbOx "Single row only"
....etc

However, you Input Prompt is somewhat confusing. Instead of "Select Column
to Work on", use "Select a single row".

NickHK

wrote in message
oups.com...
Hi,

My sheet has about 30 rows. I want the user to select only one row and
that row gets copied to a new sheet.

The Code to let the user select the row is

Set rng = Application.InputBox(prompt:="Select Column to Work on",
Type:=8)
rng.Select

How do I make sure the sure only one row is selected?

If more than one row is selected I need to display an error message.

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I check the number of rows selected

Gary & NickHK,

Thanks for you help. It worked.

Dhruba

Gary Keramidas wrote:
something like this

Sub test()
If Selection.Rows.Count 1 Then
MsgBox "please select only 1 row"
Else
'your code
End If

End Sub

--


Gary


"NickHK" wrote in message
...
If rng.Rows.count 1 then
MsgbOx "Single row only"
...etc

However, you Input Prompt is somewhat confusing. Instead of "Select Column
to Work on", use "Select a single row".

NickHK

wrote in message
oups.com...
Hi,

My sheet has about 30 rows. I want the user to select only one row and
that row gets copied to a new sheet.

The Code to let the user select the row is

Set rng = Application.InputBox(prompt:="Select Column to Work on",
Type:=8)
rng.Select

How do I make sure the sure only one row is selected?

If more than one row is selected I need to display an error message.

Thanks




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
VBA how to check if entire row is selected? Jack Sons Excel Discussion (Misc queries) 6 April 23rd 23 09:00 PM
How to fix a number of rows below the selected cells? sk Excel Discussion (Misc queries) 0 March 9th 10 01:56 AM
Copy a selected number of rows Eric S. Excel Discussion (Misc queries) 4 June 25th 07 08:23 AM
Finding the minimum in a selected number of rows of the same colum Mark Rugers Excel Worksheet Functions 5 July 20th 05 10:37 PM
check for selected columns in a macro philip watson Excel Programming 1 December 2nd 03 09:48 PM


All times are GMT +1. The time now is 12:03 PM.

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

About Us

"It's about Microsoft Excel"