Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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" wrote in message news:oberon.black.1uvb2b_1125893105.7414@excelforu m-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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Of course with the "With ActiveSheet" you used, the periods are required.
Jon "Jon" 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" wrote in message news:oberon.black.1uvb2b_1125893105.7414@excelforu m-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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Great works like a char -- oberon.blac ----------------------------------------------------------------------- oberon.black's Profile: http://www.excelforum.com/member.php...fo&userid=2673 View this thread: http://www.excelforum.com/showthread.php?threadid=40185 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
baby | Excel Discussion (Misc queries) | |||
Baby stuff I know-if | Excel Discussion (Misc queries) | |||
Baby Sleep log | Charts and Charting in Excel | |||
baby charts | Excel Discussion (Misc queries) | |||
Baby steps..... | Excel Discussion (Misc queries) |