DR21
DR21

Reputation: 23

Getting Text Value from Userform Text Box to Current Selected Cell in Worksheet

Cliffnotes: I am trying to get the value I entered in TextBox2 of my Userform to be inserted in the active cell. Currently I am getting an error message that says "Object required".

Full story: I am new to VBA and trying to create a Userform where you can enter a value in the TextBox2 and hit a button which would run my macro that does the following: find the column named "Dummy", add a column to the immediate left of the dummy column, copy the formulas from the right to that new column, and insert the value I entered in the TextBox2 in the active cell (which is 4 rows down from row 1 of the new column). Any help is appreciated. Thank you.

'Adding a column to the left of DUMMY
    Sheets("Collateral Strat").Select
    Dim DUMMY As Range
    Set DUMMY = Range("C5:DD5").Find("DUMMY")
    If DUMMY Is Nothing Then
             MsgBox "DUMMY column was not found."
        Exit Sub
    Else
      Columns(DUMMY.Column).Offset(, 0).Resize(, 1).Insert
    End If
    
'CTRL+Spacebar
    ActiveCell.EntireColumn.Select
'CTRL+R
    Selection.FillRight
    ActiveCell.Offset(4, 0).Select
'this doesnt work yet
    ActiveCell.Text = TextBox2.Text

Upvotes: 0

Views: 910

Answers (1)

Gary's Student
Gary's Student

Reputation: 96753

Replace:

ActiveCell.Text = TextBox2.Text

with:

ActiveCell.Value = TextBox2.Text

Remember .Text is read-only.

Upvotes: 1

Related Questions