+ Reply to Thread
Results 1 to 6 of 6

update or amend worksheet

Hybrid 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.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I'm not clear what you want, but take a look at the database form here

    http://www.excel-it.com/vba_examples.htm
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

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

    Resolved

    Thanks but that is where i got the code from to populate the text boxes
    but could not see how to use it to update a worksheet
    cheers
    Doug
    Last edited by dougvcd; 06-07-2008 at 02:30 PM.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    There's an amend record button that updates a selected record.

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

    Red face

    cheers for that i was looking at diff prog
    working ok at moment
    cheers
    Doug

  6. #6
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717
    Hi,

    if u can update that excel sheet till whatever u hav done and clearly metion ur requirement .. i wod be able to help you out

+ 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