Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Stupid Excel VBA Question

  • 26-09-2011 7:23pm
    #1
    Registered Users, Registered Users 2 Posts: 602 ✭✭✭


    Really cannot believe I cannot get this work,

    two text boxes on two seperate sheets, after a click event I want textbox 1 to write to textbox one on another sheet

    Worksheets("sheet1").TextBox1.Value = Worksheets("sheet2").TextBox1

    the value just seems dissapear, I have removed the .value and .text but nothing, the value of textbox just dissapears.

    these are embedded text boxes and not on a form which I have never tried before,

    any ideas??


Comments

  • Moderators, Politics Moderators Posts: 41,235 Mod ✭✭✭✭Seth Brundle


    Set breakpoints within your code (press F9 on one of the lines) and then step through your code (F8) - this should show you where its breaking.

    However, is there an event on both text boxes?
    If so then add something like Application.EnableEvents = False
    and turn it back on (by setting it to True (and same again in your error handling code).

    However, the following works fine for me:
    Private Sub CommandButton1_Click()
    On Error GoTo ThePub
        Me.TextBox1.Value = Sheets("Sheet2").TextBox1.Value
        Exit Sub
    ThePub:
        MsgBox Err.Description, vbExclamation, "My App"
    End Sub
    
    (bearing in mind the control names are the defaults.


  • Registered Users, Registered Users 2 Posts: 898 ✭✭✭OREGATO


    By the looks of it, you're missing '.Value' at the end of the line.

    Worksheets("sheet1").TextBox1.Value = Worksheets("sheet2").TextBox1

    As shown in the post by kbannon, he has:

    Me.TextBox1.Value = Sheets("Sheet2").TextBox1.Value
    HTH


  • Registered Users, Registered Users 2 Posts: 602 ✭✭✭Gator


    Still couldnt get it to work,very strange, i just wrote the values to cells instead, cheers


  • Moderators, Politics Moderators Posts: 41,235 Mod ✭✭✭✭Seth Brundle


    Are they form controls or ActiveX controls?


Advertisement