+ Reply to Thread
Results 1 to 15 of 15

Data Entry VBA on next empty column

Hybrid View

  1. #1
    Registered User
    Join Date
    03-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2013
    Posts
    66

    Data Entry VBA on next empty column

    Guys, may I ask for your help? I've searched tutorials on this but i can't find the right answer to my problem.

    1.I've watched tutorials on youtube but the data entry was on the next row. I want that my data entry to input data on the next blank column. I'm having problem with the code to use

    2. And i hope that there's a way that the P.O. number will arrange in ascending order.

    Example :
    The last P.O. number was 005 then i've realize that I've missed P.O. number 003. And I want to input P.O. number 003 and it will be arrange.

    untitled.jpg
    Last edited by chubbyjenz; 07-14-2014 at 01:19 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Data Entry VBA on next empty column

    Was there not a tutorial on how to sort using vba for point 2?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    03-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2013
    Posts
    66

    Re: Data Entry VBA on next empty column

    hi, i think i've found something in here for point 2.

    my main concern is my question number 1.

    can you help me with this one pls?

  4. #4
    Forum Contributor
    Join Date
    08-17-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Data Entry VBA on next empty column

    Upload a sample file..

  5. #5
    Registered User
    Join Date
    03-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2013
    Posts
    66

    Re: Data Entry VBA on next empty column

    Book1.xlsm

    this is the file. What i want is whenever i input the date, the P.O. number, it will input in a column.

  6. #6
    Registered User
    Join Date
    03-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2013
    Posts
    66

    Re: Data Entry VBA on next empty column

    hi guys.. ill just bring this UP.. hope someone can help.

  7. #7
    Registered User
    Join Date
    03-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2013
    Posts
    66

    Re: Data Entry VBA on next empty column

    Hello guys, ill bring up my post..

  8. #8
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Data Entry VBA on next empty column

    perhaps
    Private Sub CommandButton1_Click()
    Dim NextCol1 As Long
    Dim NextCol2 As Long
    Dim NextCol3 As Long
           
        With ActiveSheet
             
            NextCol1 = .Cells(2, .Columns.Count).End(xlToLeft).Column + 1
            If TextBox1.Value <> "" Then
            .Cells(2, NextCol1) = TextBox1.Value
            Else
            End If
             NextCol2 = .Cells(3, .Columns.Count).End(xlToLeft).Column + 1
             If TextBox2.Value <> "" Then
            .Cells(3, NextCol2) = TextBox2.Value
            Else
            End If
              NextCol3 = .Cells(5, .Columns.Count).End(xlToLeft).Column + 1
             If TextBox3.Value <> "" Then
            .Cells(5, NextCol3) = TextBox3.Value
            Else
            End If
          
            'and so on
        End With
    End Sub
    Last edited by john55; 07-12-2014 at 12:15 PM.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  9. #9
    Registered User
    Join Date
    03-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2013
    Posts
    66

    Re: Data Entry VBA on next empty column

    thank you so much john55. i hope you can help me again next time.

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Data Entry VBA on next empty column

    you're welcome. glad I could be of help.
    if you are happy with the solution provided, please mark the thread as "Solved". thank you!

  11. #11
    Registered User
    Join Date
    03-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2013
    Posts
    66

    Re: Data Entry VBA on next empty column

    hey john, i'm trying to add another code.

    1. Clearing the userform after pressing submit by using
    textbox.value = ""

    and

    2. adding MSGbox to the PO number if the data is not a number and to the date.

    MsgBox "The P.O. No. box must contain a number.", vbExclamation
    Me.POnumber.SetFocus



    and one more thing,

    3. How can i add a confirmation message that when the submit button is press, a dialogue box or something will pop up saying something like "Are you sure blah blah blah?"

    It will pop up a message box, however, it will still input the data in the userform. how can i prevent this?
    Last edited by chubbyjenz; 07-12-2014 at 03:00 PM.

  12. #12
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Data Entry VBA on next empty column

    hope it helps you
    Private Sub CommandButton1_Click()
    'the question
    If MsgBox("Do you want to add it?!", vbYesNo + vbQuestion, "Confirm?!") = vbYes Then
    Dim NextCol1 As Long
    Dim NextCol2 As Long
    Dim NextCol3 As Long
     'and so on
        With ActiveSheet
             
            NextCol1 = .Cells(2, .Columns.Count).End(xlToLeft).Column + 1
            If TextBox1.Value <> "" Then
            .Cells(2, NextCol1) = TextBox1.Value
            Else
            End If
             NextCol2 = .Cells(3, .Columns.Count).End(xlToLeft).Column + 1
            
             If TextBox2.Value <> "" Then
            .Cells(3, NextCol2) = TextBox2.Value
            Else
            End If
              NextCol3 = .Cells(5, .Columns.Count).End(xlToLeft).Column + 1
             If TextBox3.Value <> "" Then
            .Cells(5, NextCol3) = TextBox3.Value
            Else
            End If
          
            'and so on
        End With
        End If
        'clear the textboxes
        TextBox1.Value = ""
        TextBox2.Value = ""
        TextBox3.Value = ""
        '
    End Sub
    
    
    Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    'the po box no format
    If TypeName(Me.ActiveControl) = "TextBox" Then
            With Me.ActiveControl
                If Not IsNumeric(.Value) And .Value <> vbNullString Then
                    MsgBox "Sorry, ""The PO No box"" only numbers allowed!", vbCritical, "oops"
                    .Value = vbNullString
                    .SetFocus
                End If
            End With
       End If
      
    End Sub

  13. #13
    Registered User
    Join Date
    03-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2013
    Posts
    66

    Re: Data Entry VBA on next empty column

    Thanks again john55 . You're the best!

    however, is there a shortcut for these?

    1. Error message when none of those 7 textboxes (not including the date and the PO number) are not filed up if you press submit

    2. Error message when inputs from any of those 7 textboxes (not including the date and the PO number) is not a number.


    is there a shortcut for this? because i will be working on my next excel userform with 40 textboxes and i want to know my options.

    Hope you can help.

  14. #14
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Data Entry VBA on next empty column

    You're welcome!
    your new requirements are not reflected by the thread title, I think you need to open a new one....

  15. #15
    Registered User
    Join Date
    03-26-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2013
    Posts
    66

    Re: Data Entry VBA on next empty column

    thank you john55.

    i've already created a new thread.. i hope you can help me again this time.

+ 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. [SOLVED] Worksheet_Change - allow row data entry in column 10 only when columns 1-9 are not empty
    By tv69 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-25-2014, 03:33 PM
  2. [SOLVED] Userform data entry to first empty occurence of name
    By markmellow in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2012, 02:41 PM
  3. [SOLVED] counting empty cells in a row before first data entry
    By bonviveur60 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-27-2012, 08:21 PM
  4. Replies: 0
    Last Post: 10-06-2011, 07:03 AM
  5. how to reset data entry cells to 0 or empty
    By Bruce in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-14-2006, 10:10 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