Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i have 151 rows of data in my excel spreedsheet. The data gets entered through a Userform1. I want to be able to generate a receipt for the user by using the txtname field. I also would like the txtpo, txtdate, txtaddress on this receipt. the only problem is that each row has a different name date, address etc... i have tried the following to no avail. i think maybe some kind of search first on the name fireld then ???? I don't know, I'm lost - can anybody please assist.

    Code:
    Private Sub CMDshowLabel_Click() 
       UserForm1.TextBoxDate.Text = Range("A1").Value 
       UserForm1.TextBoxName.Text = Range("B1").Value 
       UserForm1.Show 
    End Sub
    Code:
    Private Sub CMDprint_Click() 
       UserForm1.printform 
    End Sub

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,435
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Try this:
    Code:
    Private Sub CMDshowLabel_Click() 
       UserForm1.Show 
    End Sub
    In the UserForm Code:

    Code:
    Private Sub UserForm_Initialize() 
       With ActiveCell
          TextBoxDate.Text = .Value 
          TextBoxName.Text = .Offset(0,1).Value 
           '*** Etc... *** 
       End With
    End Sub
    The above assumes the user has selected the record to be printed as a receipt before clicking the command button! It also assumes they selected the Date in col A! If you have users who don't follow instructions well you may need to add code to position the cursor at the beginning of the row, i.e. Col A. Ex: Selection.End(xlToLeft).Select
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •