Results 1 to 2 of 2

Set height of txtbox in form to auto with fixed width and set other txtbox to same height

Threaded View

scampie Set height of txtbox in form... 09-22-2021, 06:11 PM
karmapala Re: Set height of txtbox in... 09-23-2021, 12:25 AM
  1. #1
    Registered User
    Join Date
    02-18-2014
    Location
    england
    MS-Off Ver
    2019
    Posts
    13

    Set height of txtbox in form to auto with fixed width and set other txtbox to same height

    Excuse the crappy layout! Making pretty isn't worth it till it works!

    I am creating a form which displays sales records. The problem I have is when displaying the quantity, sku, Title, price. Ideally a table would work perfectly, but I can't figure out if this is possible. It does auto populate, but I've left generic info on the pic.

    Crappy pic pointing to the text boxes in question.The title tends to be a few lines long, I need to set the item Title txtbox to be a set width but an auto height. I then need the quantity, sku and price txtboxes to match the height of the quantity txtbox. I'm looking for an invoice style layout.

    At present I'm only working on the first item, I'll need to add the second item after this, hence why I want these to align.

    Current code pinched from the fabulous interwebz:

    Option Explicit
    'Where the procedure called Findit is called after Enter is clicked.
    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = vbKeyReturn Then
    Findit
    End If
    End Sub
    
    Private Sub Findit() 'Find and populate the records with Excel VBA
    Dim fnd As Range
    Dim Search As String
    Dim sh As Worksheet
    Dim i As Integer
    
    Set sh = Sheet9
    Search = TextBox1.Text
    Set fnd = sh.Columns("A:A").Find(Search, , , xlWhole)
    
    If fnd Is Nothing Then
    MsgBox "No Person Found", , "Error"
    TextBox1.Text = ""
    Else
    For i = 2 To 28 'There are 30? items in the userform.
    Frm_sales.Controls("TextBox" & i).Text = sh.Cells(fnd.Row, i).Value
    Next i
    End If
    End Sub
    Apologies for my naivety. VBA is not something I practise, so while I'm not asking for complete answers, I'd appreciate being pointed in the right direction if anyone can advise, thanks!

    Inkedscreen shot of sales sheet_LI.jpg
    Attached Images Attached Images
    Last edited by scampie; 09-23-2021 at 02:52 AM. Reason: Add code

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Check box if true copy txtbox 1 to txtbox 2
    By mmikem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2019, 02:27 PM
  2. Replies: 0
    Last Post: 02-13-2016, 03:31 AM
  3. Replies: 3
    Last Post: 03-22-2013, 12:19 AM
  4. Replies: 0
    Last Post: 03-29-2012, 01:05 PM
  5. Macro for fixed column width and row height across multiple sheets
    By westbay in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-09-2011, 03:15 AM
  6. [SOLVED] auto fit column width and row height
    By kb in forum Excel General
    Replies: 0
    Last Post: 05-22-2006, 03:00 PM
  7. [SOLVED] UserForm TextBox with fixed Width and dynamic Height
    By Soniya in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-04-2006, 04:45 AM

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