+ Reply to Thread
Results 1 to 2 of 2

Select only one column/row in a range

  1. #1
    Forum Contributor
    Join Date
    04-30-2004
    Posts
    122

    Select only one column/row in a range

    I have an input box which I use to select a range of cells. Is there any code I can add which will allow the user to select from only 1 column or row at a time. For instance, the user can only select fom A1:A10 not A1:B10 or the user can only select A1:G1 not A1:G2 etc etc.

    Here is the simple code that I use for the input box..

    Set Range1 = Application.InputBox(prompt:= _
    "Select range....", Type:=8)

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451

    Select only one column/row in a range

    Paste this macro in sheet where you want cells of only 1 row or one column to be selected.


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Rows.Count > 1 And Target.Columns.Count > 1 Then
    MsgBox "you can only select cells from one column or one row"
    Range("a1").Select
    End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1