Results 1 to 6 of 6

update or amend worksheet

Threaded View

  1. #1
    Registered User
    Join Date
    04-28-2008
    Location
    Plymouth UK
    Posts
    17

    update or amend worksheet

    ok have a work sheet and userform which is populated from worksheet
    this is the code i use to populate text boxes

    Option Explicit
    Dim cl         As Range
    
    Private Sub CommandButton1_Click()
        'get the next line of data
        Set cl = ActiveCell.Offset(1, 0)
        'switch off ScreenUpdating to speed up code & prevent flickering
        Application.ScreenUpdating = False
        cl.Select
        'if there is no more data then notify the user & quit
        If cl.Value = "" Then
            TextBox1.Value = "No more Data"
            TextBox2.Value = ""
            Exit Sub
        Else
            'load UserForm with fresh data
            TextBox1.Value = cl.Value
            TextBox2.Value = cl.Offset(0, 1).Value
            TextBox3.Value = cl.Offset(0, 2).Value
            TextBox4.Value = cl.Offset(0, 3).Value
        End If
        'restore ScreenUpdating
        Application.ScreenUpdating = True
    End Sub
    
    Private Sub CommandButton2_Click()
    Unload Me
    End Sub
    
    Private Sub UserForm_Initialize()
        'select the first cell in the column of data
        Set cl = Cells(2, 1)
        cl.Select
        'enter the required data into the textBoxes
        TextBox1.Value = cl.Value
        TextBox2.Value = cl.Offset(0, 1).Value
        TextBox3.Value = cl.Offset(0, 2).Value
        TextBox4.Value = cl.Offset(0, 3).Value
    End Sub
    how can i use this to also update if i change any data in the text boxes if you see what i mean
    cheers
    Doug
    Last edited by VBA Noob; 06-07-2008 at 11:20 AM.

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