+ Reply to Thread
Results 1 to 2 of 2

Adding new lines from a 'form'

Hybrid View

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    Nottingham
    MS-Off Ver
    Excel 2007
    Posts
    2

    Adding new lines from a 'form'

    Hi All

    I have created a basic form:
    Picture1.jpg

    When I click the 'Add to Schedule' button I would like to execute a macro that drops this information into the next available row in this table:
    Picture2.jpg

    If someone could show me the VB code for getting the information in the 'On Sale' part of the form into the next available row in column C, I am sure I can modify the the coding for the other info!

    Thanks!

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Post Re: Adding new lines from a 'form'

    Try this Function to get the next available row for data entry on any sheet.

    Sub test()
     Dim lr As Long
     
       ' Call NextAvailableRow for any Worksheet that you are looking for the next available row.
       ' First param is WhatSheet = Worksheet Name as string
       ' Second param is WhatColumn = Column as string
        lr = NextAvailableRow("WorksheetName", "C")
        
        ' Do something now we lastrow
        Worksheets("WorksheetName").Range("A" & lr) = ""
        
    End Sub
    Function NextAvailableRow(WhatSheet As String, WhatColumn As String) As Long
        If Application.Version <= 11 Then
            NextAvailableRow = Worksheets(WhatSheet).Cells(Rows.Count, WhatColumn).End(xlUp).Row + 1
        Else
            NextAvailableRow = Worksheets(WhatSheet).Cells(Rows.CountLarge, WhatColumn).End(xlUp).Row + 1
        End If
    End Function

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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