+ Reply to Thread
Results 1 to 5 of 5

Using userform, text boxes

  1. #1
    Momo
    Guest

    Using userform, text boxes

    Hi,

    I'm using an excel help book to try and write a macro, well specifically a
    userform part of a macro, the userform contains 40 text boxes and three
    comand buttons, i have created the userform, but as usual the book macro
    varies quite a lot from the macro i am trying to write, i have declared my
    variables, created a spreadsheet with my variables, (default and current)
    with named ranges for selection of the required cell. the stage i am at with
    the code i have written i would expect when i run my macro for the userform
    to open displaying the default data in the text boxes but instead i get an
    error message with a debug option (line highlighted with a ** below)


    ***********************************(Module 1)

    Public CC1 'Cost Centre 1
    Public CC2 'Cost Centre 2
    Public CC3 'Cost Centre 3
    Public CC4 'Cost Centre 4


    Sub CCOptions()
    ' Userform 1(Cost Centre) options

    With Worksheets("MacroDAta")

    CC1 = .Range("CC1_ default").Value
    CC2 = .Range("CC2_ default").Value
    CC3 = .Range("CC3_ default").Value
    CC4 = .Range("CC4_ default").Value
    End With

    With UserForm1

    ** CC1TextBox.Vale = CC1**
    CC2TextBox.Value = CC2
    CC3TextBox.Value = CC3
    CC4TextBox.Value = CC4

    End With

    UserForm1.Show

    End Sub
    *********************************

    *********************************(Microsoft Excel objects(Sheet 1))


    Sub upload()

    LoadVariables 'Load Public Variables

    End Sub

    Private Sub CommandButton1_Click()

    CommandButton1.Caption = "P r i n t A l l"

    CCOptions

    End Sub
    ***************************************

    That is all my code thus far, (i have cut it down was CC1 to CC45, i dont
    understand where i'm going wrong thus far (plus the userform sheet, text
    boxes labelled CC1textbox, etc), please any help,

    thanks

    Andy



  2. #2
    Robin Hammond
    Guest

    Re: Using userform, text boxes

    Momo,

    Sounds like you are learning fast.

    Try
    .CC1TextBox.Text = CC1

    'note the dot in front of CC1TextBox
    and .Text for the subsequent boxes.

    Robin Hammond
    www.enhanceddatasystems.com


    "Momo" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I'm using an excel help book to try and write a macro, well specifically a
    > userform part of a macro, the userform contains 40 text boxes and three
    > comand buttons, i have created the userform, but as usual the book macro
    > varies quite a lot from the macro i am trying to write, i have declared my
    > variables, created a spreadsheet with my variables, (default and current)
    > with named ranges for selection of the required cell. the stage i am at
    > with
    > the code i have written i would expect when i run my macro for the
    > userform
    > to open displaying the default data in the text boxes but instead i get an
    > error message with a debug option (line highlighted with a ** below)
    >
    >
    > ***********************************(Module 1)
    >
    > Public CC1 'Cost Centre 1
    > Public CC2 'Cost Centre 2
    > Public CC3 'Cost Centre 3
    > Public CC4 'Cost Centre 4
    >
    >
    > Sub CCOptions()
    > ' Userform 1(Cost Centre) options
    >
    > With Worksheets("MacroDAta")
    >
    > CC1 = .Range("CC1_ default").Value
    > CC2 = .Range("CC2_ default").Value
    > CC3 = .Range("CC3_ default").Value
    > CC4 = .Range("CC4_ default").Value
    > End With
    >
    > With UserForm1
    >
    > ** CC1TextBox.Vale = CC1**
    > CC2TextBox.Value = CC2
    > CC3TextBox.Value = CC3
    > CC4TextBox.Value = CC4
    >
    > End With
    >
    > UserForm1.Show
    >
    > End Sub
    > *********************************
    >
    > *********************************(Microsoft Excel objects(Sheet 1))
    >
    >
    > Sub upload()
    >
    > LoadVariables 'Load Public Variables
    >
    > End Sub
    >
    > Private Sub CommandButton1_Click()
    >
    > CommandButton1.Caption = "P r i n t A l l"
    >
    > CCOptions
    >
    > End Sub
    > ***************************************
    >
    > That is all my code thus far, (i have cut it down was CC1 to CC45, i dont
    > understand where i'm going wrong thus far (plus the userform sheet, text
    > boxes labelled CC1textbox, etc), please any help,
    >
    > thanks
    >
    > Andy
    >
    >




  3. #3
    Momo
    Guest

    RE: Using userform, text boxes


    quick note, error isn't because i have spelt value wrong, that is something
    i have done while trying to solve the problem.

    Thanks

    Andy

  4. #4
    Jean-Yves
    Guest

    Re: Using userform, text boxes

    Hi,

    Missing dot ?=> .CC1TextBox.Vale = CC1
    Typing mistake : .CC1TextBox.ValUe = CC1
    Regards,
    JY

    > With UserForm1
    >
    > ** CC1TextBox.Vale = CC1**
    > CC2TextBox.Value = CC2
    > CC3TextBox.Value = CC3
    > CC4TextBox.Value = CC4
    >
    > End With


    "Momo" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I'm using an excel help book to try and write a macro, well specifically a
    > userform part of a macro, the userform contains 40 text boxes and three
    > comand buttons, i have created the userform, but as usual the book macro
    > varies quite a lot from the macro i am trying to write, i have declared my
    > variables, created a spreadsheet with my variables, (default and current)
    > with named ranges for selection of the required cell. the stage i am at

    with
    > the code i have written i would expect when i run my macro for the

    userform
    > to open displaying the default data in the text boxes but instead i get an
    > error message with a debug option (line highlighted with a ** below)
    >
    >
    > ***********************************(Module 1)
    >
    > Public CC1 'Cost Centre 1
    > Public CC2 'Cost Centre 2
    > Public CC3 'Cost Centre 3
    > Public CC4 'Cost Centre 4
    >
    >
    > Sub CCOptions()
    > ' Userform 1(Cost Centre) options
    >
    > With Worksheets("MacroDAta")
    >
    > CC1 = .Range("CC1_ default").Value
    > CC2 = .Range("CC2_ default").Value
    > CC3 = .Range("CC3_ default").Value
    > CC4 = .Range("CC4_ default").Value
    > End With
    >
    > With UserForm1
    >
    > ** CC1TextBox.Vale = CC1**
    > CC2TextBox.Value = CC2
    > CC3TextBox.Value = CC3
    > CC4TextBox.Value = CC4
    >
    > End With
    >
    > UserForm1.Show
    >
    > End Sub
    > *********************************
    >
    > *********************************(Microsoft Excel objects(Sheet 1))
    >
    >
    > Sub upload()
    >
    > LoadVariables 'Load Public Variables
    >
    > End Sub
    >
    > Private Sub CommandButton1_Click()
    >
    > CommandButton1.Caption = "P r i n t A l l"
    >
    > CCOptions
    >
    > End Sub
    > ***************************************
    >
    > That is all my code thus far, (i have cut it down was CC1 to CC45, i dont
    > understand where i'm going wrong thus far (plus the userform sheet, text
    > boxes labelled CC1textbox, etc), please any help,
    >
    > thanks
    >
    > Andy
    >
    >




  5. #5
    Momo
    Guest

    RE: Using userform, text boxes

    Just as i write that i have found my problem, thanks anyway all,

    Andy

    "Momo" wrote:

    > Hi,
    >
    > I'm using an excel help book to try and write a macro, well specifically a
    > userform part of a macro, the userform contains 40 text boxes and three
    > comand buttons, i have created the userform, but as usual the book macro
    > varies quite a lot from the macro i am trying to write, i have declared my
    > variables, created a spreadsheet with my variables, (default and current)
    > with named ranges for selection of the required cell. the stage i am at with
    > the code i have written i would expect when i run my macro for the userform
    > to open displaying the default data in the text boxes but instead i get an
    > error message with a debug option (line highlighted with a ** below)
    >
    >
    > ***********************************(Module 1)
    >
    > Public CC1 'Cost Centre 1
    > Public CC2 'Cost Centre 2
    > Public CC3 'Cost Centre 3
    > Public CC4 'Cost Centre 4
    >
    >
    > Sub CCOptions()
    > ' Userform 1(Cost Centre) options
    >
    > With Worksheets("MacroDAta")
    >
    > CC1 = .Range("CC1_ default").Value
    > CC2 = .Range("CC2_ default").Value
    > CC3 = .Range("CC3_ default").Value
    > CC4 = .Range("CC4_ default").Value
    > End With
    >
    > With UserForm1
    >
    > ** CC1TextBox.Vale = CC1**
    > CC2TextBox.Value = CC2
    > CC3TextBox.Value = CC3
    > CC4TextBox.Value = CC4
    >
    > End With
    >
    > UserForm1.Show
    >
    > End Sub
    > *********************************
    >
    > *********************************(Microsoft Excel objects(Sheet 1))
    >
    >
    > Sub upload()
    >
    > LoadVariables 'Load Public Variables
    >
    > End Sub
    >
    > Private Sub CommandButton1_Click()
    >
    > CommandButton1.Caption = "P r i n t A l l"
    >
    > CCOptions
    >
    > End Sub
    > ***************************************
    >
    > That is all my code thus far, (i have cut it down was CC1 to CC45, i dont
    > understand where i'm going wrong thus far (plus the userform sheet, text
    > boxes labelled CC1textbox, etc), please any help,
    >
    > thanks
    >
    > Andy
    >
    >


+ 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