title: Textbox.value as a variable
body: <p>I need to copy an input in a textbox and transform this in a variable that will be used as a range. With the code described below i'm facing error 91 Object variable or With block variable not set. If you have a better way to do this, please let me know.</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  Dim rng As String
  Dim rangeA As Range
  Dim rangeB As Range
  Dim rangeC As Range
  Dim rangeD As Range
  Dim rangeE As Range
  
  rng = TextBoxA.Value
  
  If IsNumeric(RangeboxA.Value) Then
  On Error Resume Next
  Set rangeA = Sheets("Plan1").Range(RangeboxA.Value)
  On Error GoTo 0
  If rangeA Is Nothing Then MsgBox "Range A inválido"
  
  End If
  
  rangeA.Select
  Selection.Cut
  rangeA.Offset(0, rng).Select
  
      ActiveSheet.Paste
  
  rng = TextBoxB.Value
  
  
   Range("B3:E3").Select
   Selection.Cut
   Range("B3").Offset(0, rng).Select
  
       ActiveSheet.Paste
  
  rng = TextBoxC.Value
  
  
  Range("B4:E4").Select
  Selection.Cut
  Range("B4").Offset(0, rng).Select
  
      ActiveSheet.Paste
  
  rng = TextBoxD.Value
  
  
  Range("B5:E5").Select
  Selection.Cut
  Range("B5").Offset(0, rng).Select
  
      ActiveSheet.Paste
  
  rng = TextBoxE.Value
  
  
  Range("B6:E6").Select
  Selection.Cut
  Range("B6").Offset(0, rng).Select
  
      ActiveSheet.Paste
  
  Me.Hide
  End Sub
  </code></pre>