Results 1 to 7 of 7

Vba code to populate cells based on textbox value

Threaded View

  1. #1
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Vba code to populate cells based on textbox value

    Hi All

    I have the below code which populates a copy of a template sheet called Invoice. It works perfectly. Only problem I have is that the items captured are in random orders. What I want to achieve is to split the way it populates based on a textbox value. Invoice is currrent outcome and New Invoice is the result I want to achieve.

    ws1.Select
    With ws1
    For v = 7 To 20
        If ws1.Cells(v, 2) = Item Then
        Cells(v, 1).Value = CInt(Cells(v, 1).Value) + CInt(UserForm1.TextBox2.Value)
        Cells(v, 4) = Format(Cells(v, 1), "0.00") * Format(TextBox3, "0.00")
        Cells(v, 4).NumberFormat = "#,###.00"
        'TextBox1 = ""
        'TextBox2 = ""
        'TextBox3 = ""
        'TextBox9 = ""
        'TextBox11 = ""
        GoTo next_sheet
        End If
    Next
    End With
    
    With ws1.Range("a4")
        .End(xlDown).Offset(1).Resize(, 4) = Array(TextBox2, TextBox1, Format(TextBox3, "0.00"), Format(TextBox2, "0.00") * Format(TextBox3, "0.00"))
        .End(xlDown).Offset(1).EntireRow.Insert shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        .End(xlDown).Offset(1, 2).NumberFormat = "0.00"
        .End(xlDown).Offset(1, 3).NumberFormat = "0.00"
    End With

    Somewhere, i need to add a If statement that checks the following:
    If UserForm.TextBox11 = "BP" Then
    'Populate above beverages
    ElseIf 
    UserForm.TextBox11 = "KP" Then
    'Populate above food
    End If
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Auto populate textbox value based on combobox value
    By justin1202 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-30-2015, 04:01 AM
  2. [SOLVED] trying to populate a list box based on textbox value
    By justlearning123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-08-2015, 08:41 PM
  3. Textbox to populate based on combobox selection
    By acroley1 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-11-2015, 04:12 PM
  4. [SOLVED] Need to populate data in listbox based on textbox value change
    By Naveed Raza in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-20-2014, 07:10 AM
  5. Populate textbox based off ComboBox Selection
    By ladams41 in forum Excel General
    Replies: 1
    Last Post: 04-09-2014, 10:13 AM
  6. Populate TextBox based off ComboBox selection
    By ladams41 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2014, 01:24 PM
  7. Populate a column based on input from a textbox
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2012, 03:39 PM

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