+ Reply to Thread
Results 1 to 2 of 2

Displaying cell contents in user forms

Hybrid View

  1. #1
    Registered User
    Join Date
    09-15-2008
    Location
    UK
    Posts
    1

    Displaying cell contents in user forms

    I am currently putting together userform to input records to a data base, adding the new record to the first available row. So far so good. Column A is unique reference field which is currently prenumbered. What I want to do is display the value of this for the current record in a text box on the input userform.



    I can't help thinking there is a simple solution but I don't know what it is.



    Any help anyone please.

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    It's hard to answer this without visualizing your data. Where is this current number being stored? Is it in a worksheet? If so, simply set the textbox value equal to the cell in question (see sample code below)

    Private Sub UserForm_Initialize()
        Dim LastRow As Long
        Dim CurrentNumber As Long
        
        LastRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
        CurrentNumber = CLng(Sheet1.Cells(LastRow, 1).Value)
        
        TextBox1.Value = CurrentNumber
    End Sub
    Let me know if that helps.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Link User Form Text Box to worksheet cell
    By jamphan in forum Excel General
    Replies: 11
    Last Post: 07-20-2014, 10:45 AM
  2. How to edit contents in Cell
    By hrukmini in forum Excel General
    Replies: 1
    Last Post: 05-11-2008, 10:36 PM
  3. When deleting cell contents, they come right back?
    By Paul987 in forum Excel General
    Replies: 3
    Last Post: 03-24-2008, 02:08 PM
  4. using cell content to reference a worksheet tab name in second workbook
    By Conor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2007, 09:32 AM
  5. checking cell contents and displaying a message
    By brownstone in forum Excel General
    Replies: 4
    Last Post: 05-24-2007, 05:54 PM

Tags for this Thread

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