+ Reply to Thread
Results 1 to 5 of 5

Baby steps

  1. #1
    Forum Contributor
    Join Date
    08-28-2005
    Posts
    132

    Baby steps

    I have the following code linked to a userform:

    Please Login or Register  to view this content.
    I have added a description field to my userform. This field is to add a title to the newly created column.

    What do I need to add to this code to copy the title out of the description of the userform and place it into 'row 11 ' of the column the code above inserts?

  2. #2
    Rowan
    Guest

    RE: Baby steps

    When you say you've added a description field to the userform do you mean a
    textbox? If so try:

    Private Sub CommandButton1_Click()
    With ActiveSheet
    If Me.OptionButton1 = True Then
    .Range("D12").EntireColumn.Insert
    .Range("D11").Value = Me.TextBox1.Value
    Else
    .Range("F12").EntireColumn.Insert
    .Range("F11").Value = Me.TextBox1.Value
    End If
    End With
    End Sub

    Hope this helps
    Rowan

    "oberon.black" wrote:

    >
    > I have the following code linked to a userform:
    >
    >
    > Code:
    > --------------------
    >
    > Private Sub CommandButton1_Click()
    > With ActiveSheet
    > If Me.OptionButton1 = True Then
    > .Range("d12").EntireColumn.Insert
    > Else
    > .Range("f12").EntireColumn.Insert
    > End If
    > End With
    > End Sub
    > Private Sub OptionButton1_Click()
    > Me.OptionButton1.Value = True
    > End Sub
    >
    > --------------------
    >
    >
    > I have added a description field to my userform. This field is to add
    > a title to the newly created column.
    >
    > What do I need to add to this code to copy the title out of the
    > description of the userform and place it into 'row 11 ' of the column
    > the code above inserts?
    >
    >
    > --
    > oberon.black
    > ------------------------------------------------------------------------
    > oberon.black's Profile: http://www.excelforum.com/member.php...o&userid=26732
    > View this thread: http://www.excelforum.com/showthread...hreadid=401851
    >
    >


  3. #3
    Jon
    Guest

    Re: Baby steps

    First of all, remove the periods from in front all of the words "Range" in
    your code.

    When you insert a column at "D" the new column is actually the new "D".
    If you are using a textbox to enter the description, then in the OK
    (Commandbutton1) click event you put something like the following:

    Private Sub CommandButton1_Click()
    If OptionButton1 = True Then
    Range("d12").EntireColumn.Insert
    Range("d11").Formula = TextBox1.Value
    Else
    Range("f12").EntireColumn.Insert
    Range("f11").Formula = TextBox1.Value
    End If
    Unload UserForm1
    End Sub

    I believe clicking on an optionbutton sets its value to true without the
    code below. (Have a look at Select Case for using multiple optionbuttons in
    the click event above)

    Private Sub OptionButton1_Click()
    OptionButton1.Value = True
    End Sub


    "oberon.black" <oberon.black.1uvb2b_1125893105.7414@excelforum-nospam.com>
    wrote in message
    news:oberon.black.1uvb2b_1125893105.7414@excelforum-nospam.com...
    >
    > I have the following code linked to a userform:
    >
    >
    > Code:
    > --------------------
    >
    > Private Sub CommandButton1_Click()
    > With ActiveSheet
    > If Me.OptionButton1 = True Then
    > .Range("d12").EntireColumn.Insert
    > Else
    > .Range("f12").EntireColumn.Insert
    > End If
    > End With
    > End Sub
    > Private Sub OptionButton1_Click()
    > Me.OptionButton1.Value = True
    > End Sub
    >
    > --------------------
    >
    >
    > I have added a description field to my userform. This field is to add
    > a title to the newly created column.
    >
    > What do I need to add to this code to copy the title out of the
    > description of the userform and place it into 'row 11 ' of the column
    > the code above inserts?
    >
    >
    > --
    > oberon.black
    > ------------------------------------------------------------------------
    > oberon.black's Profile:
    > http://www.excelforum.com/member.php...o&userid=26732
    > View this thread: http://www.excelforum.com/showthread...hreadid=401851
    >




  4. #4
    Jon
    Guest

    Re: Baby steps

    Of course with the "With ActiveSheet" you used, the periods are required.

    Jon
    "Jon" <jon@nospam.net> wrote in message
    news:dtQSe.216635$9A2.6207@edtnps89...
    > First of all, remove the periods from in front all of the words "Range" in
    > your code.
    >
    > When you insert a column at "D" the new column is actually the new "D".
    > If you are using a textbox to enter the description, then in the OK
    > (Commandbutton1) click event you put something like the following:
    >
    > Private Sub CommandButton1_Click()
    > If OptionButton1 = True Then
    > Range("d12").EntireColumn.Insert
    > Range("d11").Formula = TextBox1.Value
    > Else
    > Range("f12").EntireColumn.Insert
    > Range("f11").Formula = TextBox1.Value
    > End If
    > Unload UserForm1
    > End Sub
    >
    > I believe clicking on an optionbutton sets its value to true without the
    > code below. (Have a look at Select Case for using multiple optionbuttons
    > in the click event above)
    >
    > Private Sub OptionButton1_Click()
    > OptionButton1.Value = True
    > End Sub
    >
    >
    > "oberon.black" <oberon.black.1uvb2b_1125893105.7414@excelforum-nospam.com>
    > wrote in message
    > news:oberon.black.1uvb2b_1125893105.7414@excelforum-nospam.com...
    >>
    >> I have the following code linked to a userform:
    >>
    >>
    >> Code:
    >> --------------------
    >>
    >> Private Sub CommandButton1_Click()
    >> With ActiveSheet
    >> If Me.OptionButton1 = True Then
    >> .Range("d12").EntireColumn.Insert
    >> Else
    >> .Range("f12").EntireColumn.Insert
    >> End If
    >> End With
    >> End Sub
    >> Private Sub OptionButton1_Click()
    >> Me.OptionButton1.Value = True
    >> End Sub
    >>
    >> --------------------
    >>
    >>
    >> I have added a description field to my userform. This field is to add
    >> a title to the newly created column.
    >>
    >> What do I need to add to this code to copy the title out of the
    >> description of the userform and place it into 'row 11 ' of the column
    >> the code above inserts?
    >>
    >>
    >> --
    >> oberon.black
    >> ------------------------------------------------------------------------
    >> oberon.black's Profile:
    >> http://www.excelforum.com/member.php...o&userid=26732
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=401851
    >>

    >
    >




  5. #5
    Forum Contributor
    Join Date
    08-28-2005
    Posts
    132
    Great works like a charm

+ 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