Search for new line of data, ignoring first column

  • Hello everybody,


    I'm trying to make some kind of database, and for it I'm preparing userforms. I have a problem in creating a userform that enters the new data in the first available row, but with ignoring the first column. The data in the first column is created by joining data in other columns, and the column itself is not empty by default, and is used in that way because I need it for VLOOKUP formula.


    So, I'm practically a beginner in VBA and I used code I found online that I used until now, so this is the code, and I need instructions on how to adjust the code to ignore first column, and start from the 2nd:

    Code
    'find first empty row in database
    iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
        SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1


    Thank you in advance,


    Bojan

  • Re: Search for new line of data, ignoring first column


    This might be easier:


    Code
    Cells(Rows.Count, 2).End(xlUp).Row


    But be careful if you have only a header row.

  • Re: Search for new line of data, ignoring first column


    I tried your suggestion, I get an error 438.


    You could also solve my problem in another way - if you tell me the equal command to excel formula CONCATENATE in VBA, so I could put together the values of txtID_N, txtSURNAME and txtNAME.


    In that way I could avoid the data in the first column of excel table.


    EDIT:


    What I'm trying to get is something like:

    Code
    ws.Cells(iRow, 1).Value = Me.txtID_N.Value + Me.txtSURNAME.Value + Me.txtNAME.Value (with spacing between the values)
    ws.Cells(iRow, 2).Value = Me.txtID_N.Value
    ws.Cells(iRow, 3).Value = Me.txtSURNAME.Value
    ws.Cells(iRow, 4).Value = Me.txtNAME.Value
    ws.Cells(iRow, 5).Value = Me.txtJOB_TITTLE.Value


    Can you help me with this?


    Thank you,


    Bojan

  • Re: Search for new line of data, ignoring first column


    For example:


    Code
    ws.Cells(iRow, 1).Value = Me.txtID_N.Value & " " & Me.txtSURNAME.Value


    Remember to wrap your code in code tags and ask new questions in a different thread. To help people give a solution, please post sample data in a workbook.

  • Re: Search for new line of data, ignoring first column


    bojan,


    Re: post #3 - lack of code tags.


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.
    I've added the tags for you this time only. Be sure to use them in future posts.


    [COLOR="navy"]How to use code tags[/COLOR]


    [noparse]

    Code
    [/noparse]
    [COLOR="navy"]your code goes between these tags[/COLOR]
    [noparse]

    [/noparse]


    Or, just highlight all of the code and press the [COLOR="#FF0000"]#[/COLOR] button to add the code tags

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!