+ Reply to Thread
Results 1 to 4 of 4

Still working and still so much to learn

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

    Still working and still so much to learn

    I have the following code to allow me to insert a column before the column that my cursor is in. I have created a two question userform that I would like to use with the column insert code.

    the first option button on the user form ask "is this an expense"
    the second option button ask "is this income"

    I want the column to be inserted before column 'D12' if it is an expense, or before column 'F12' if it is income.

    this is the code I currently have
    Please Login or Register  to view this content.
    Can someone please help me modify it so that I can have it perform correctly according to my choice made by the userform option button.

  2. #2
    Dave Peterson
    Guest

    Re: Still working and still so much to learn

    I created a small userform with 2 optionbuttons and 2 commandbuttons.

    This was the code that I used behind the userform:

    Option Explicit
    Private Sub CommandButton1_Click()
    Unload Me
    End Sub
    Private Sub CommandButton2_Click()
    With ActiveSheet
    If Me.OptionButton1 = True Then
    .Range("d1").EntireColumn.Insert
    Else
    .Range("f1").EntireColumn.Insert
    End If
    End With
    End Sub
    Private Sub UserForm_Initialize()
    Me.OptionButton1.Value = True
    End Sub




    "oberon.black" wrote:
    >
    > I have the following code to allow me to insert a column before the
    > column that my cursor is in. I have created a two question userform
    > that I would like to use with the column insert code.
    >
    > the first option button on the user form ask "is this an expense"
    > the second option button ask "is this income"
    >
    > I want the column to be inserted before column 'D12' if it is an
    > expense, or before column 'F12' if it is income.
    >
    > this is the code I currently have
    >
    > Code:
    > --------------------
    >
    > 'Select_Insert_Column()
    > Dim MyRange As Object
    > ' Store the selected range in a variable.
    > Set MyRange = Selection
    > ' Select the entire column.
    > Selection.EntireColumn.Select
    > ' Insert Columns in all selected sheets.
    > Selection.Insert
    > ' Reselect the previously selected cells.
    > MyRange.Select
    >
    > --------------------
    >
    > Can someone please help me modify it so that I can have it perform
    > correctly according to my choice made by the userform option button.
    >
    > --
    > oberon.black
    > ------------------------------------------------------------------------
    > oberon.black's Profile: http://www.excelforum.com/member.php...o&userid=26732
    > View this thread: http://www.excelforum.com/showthread...hreadid=401827


    --

    Dave Peterson

  3. #3
    Forum Contributor
    Join Date
    08-28-2005
    Posts
    132
    thanks, awesome suggestion. However by fixing that problem creeated another one. I now need to figure out a way to keep the calulation sets together.

    here was the plan:

    that one set of figures would live between 'c12' and 'd12' and that the other set would stay between 'e12' and 'f12'.

    new problem when I insert the new column the calculation setup changes because 'e12' and 'f12' are now new blank columns.

    Any ideas on how I can keep the calculations together?

    Maybe if i give 'c12' and 'd12' a name set and 'e12' and 'f12' another name set.

    Ideas anyone.

  4. #4
    Dave Peterson
    Guest

    Re: Still working and still so much to learn

    I don't understand, but naming a range might work.

    "oberon.black" wrote:
    >
    > thanks, awesome suggestion. However by fixing that problem creeated
    > another one. I now need to figure out a way to keep the calulation
    > sets together.
    >
    > here was the plan:
    >
    > that one set of figures would live between 'c12' and 'd12' and that the
    > other set would stay between 'e12' and 'f12'.
    >
    > new problem when I insert the new column the calculation setup changes
    > because 'e12' and 'f12' are now new blank columns.
    >
    > Any ideas on how I can keep the calculations together?
    >
    > Maybe if i give 'c12' and 'd12' a name set and 'e12' and 'f12' another
    > name set.
    >
    > Ideas anyone.
    >
    > --
    > oberon.black
    > ------------------------------------------------------------------------
    > oberon.black's Profile: http://www.excelforum.com/member.php...o&userid=26732
    > View this thread: http://www.excelforum.com/showthread...hreadid=401827


    --

    Dave Peterson

+ 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