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

Visual Basic question (help please!)

  • 29-01-2009 6:01pm
    #1
    Registered Users, Registered Users 2 Posts: 929 ✭✭✭


    I will try and explain myself first.

    I am making a form in VB to co-operate with an excel spreadsheet. On this form, I want to make changes to data I have already written into excel. I have a cancel and a confirm changes button.
    I think I have the cancel button working, but I dont really know because the confirm button isnt working at all. I have no idea how to write the code for the confirm button, or really the cancel button.
    This is for the Cancel button that i have written
    
    Private Sub Command_Cancel_Click()
    gbCancel = True
    Me.Hide
    Unload Me
    End Sub
    
    This is all I have for the confirm button!
    
    Private Sub Confirm_Button_Click()
    
    Unload Me
    
    End Sub
    

    Thanks, in advance :)



    Maybe I wasn't clear enough.

    I have a userform in which i enter data. I have linked all of the boxes where I enter the data to the relavent cells in excel. But, when I press the confirm/submit button, I want it to change the values in the cells in excel to the ones I have entered in the VB form.


Comments

  • Registered Users, Registered Users 2 Posts: 163 ✭✭stephenlane80


    I presume that you are using an excel userform and that you are trying to enter a record from the userform using vba ?

    Could i suggest using MS Access for this, access is more record cenrtic than Excel, then after if you want to get you records in an Excel spread sheet you could always use a access macro to export the data to a spread sheet whenever you want,

    if you really must use excel you could use something like this in you submit event handler
    
    Private Sub Confirm_Button_Click()
    
    Worksheets("Data").Activate
    Range("A1").Activate
    
    ActiveCell.Value = FieldOne.Value
    
    ActiveCell.Offset(0, 1).Value = FieldTwo.Value
    ActiveCell.Offset(0, 2).Value = FieldThree.Value
    ActiveCell.Offset(0, 3).Value = FieldFour.Value
    
    end sub
    
    


Advertisement