Read a range from InputBox : Range « Excel « VBA / Excel / Access / Word






Read a range from InputBox

 

Public Sub SelectRange()
  Dim aRange As Range
      
  On Error Resume Next
  Set aRange = Application.InputBox(prompt:="Enter range", Type:=8)
  If aRange Is Nothing Then
    MsgBox "Operation Cancelled"
  Else
    aRange.Select
  End If
End Sub

 








Related examples in the same category

1.Deletes a range and then fills the resulting gap by shifting the other cells to the left:
2.Select a range and activate another
3.Highlights selected range
4.Modify multiple cells at once using a range reference (like A1:A2)
5.To enter the name Florence into cell C10, you assign the name to the Value property of the Range object
6.If the Range object is not in the active worksheet in the active workbook
7.Assign the value in C1 in the active sheet to D10 in the sheet named Sales, in the active workbook
8.Assign the value of a property to a variable so it can be used in later code
9.Copies the contents of range A1:B3 to the clipboard:
10.Find in a range
11.Count the blank elements in a range
12.Sum the elements in a range
13.Show Edit Ranges
14.Adding Clickable Sorting to Worksheet Lists
15.Expression refers to a cell one row below cell A1 and two columns to the right of cell A1: this refers to the cell commonly known as C2
16.Displays a message box that shows the value in cell A1 on Sheet1:
17.read the Value property only for a single- cell Range object: statement generates an error
18.Change the Value property for a range of any size: statement enters the number 123 into each cell in a range
19.Value is the default property for a Range object.
20.The Text property returns a string that represents the text as displayed in a cell: the formatted value. The Text property is read-only.
21.Count property returns the number of cells in a range (all cells, not just the nonblank cells). It's a read-only property.
22.The Column property returns the column number of a single-cell range;
23.Row property returns the row number of a single-cell range.
24.If the Range object consists of more than one cell, the Column property returns the column number of the first column in the range
25.If the Range object consists of more than one cell, the Row property returns the row number of the first row in the range.
26.Address, a read-only property, displays the cell address for a Range object in absolute notation (a dollar sign before the column letter and before the row number).
27.HasFormula property
28.Use object variables to represent the ranges
29.Building the Table
30.Returns the type of a range in an area