📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Visual Basic

I hope someone can help.

I am trying to create a Customer details form to input details into an excel spreadsheet.

I have used Visual Basic before but not for a while and I have completely forgotten how to set it up to work.

I have created the form and set up a click button to get the form up in Excel. What I am struggling with is getting the details from the form to automatically go to the next available row at the click of a button.

Can anyone help??

Comments

  • rmg1
    rmg1 Posts: 3,159
    Part of the Furniture 1,000 Posts Name Dropper
    Forumite
    First, a couple of assumptions.
    1) the data is going onto a sheet named "Sheet1"
    2) there is a save button on the userform

    In the code for the save button, you'll need something like :-
    lastcell=Sheets("sheet1").range("A65536").end(xlup)
    Sheets("sheet1").Range("A" & lastcell+1)=textbox1.text
    Sheets("sheet1").Range("B" & lastcell+1)=textbox2.text
    Sheets("sheet1").Range("C" & lastcell+1)=textbox3.text
    Sheets("sheet1").Range("D" & lastcell+1)=textbox4.text
    Sheets("sheet1").Range("E" & lastcell+1)=textbox5.text
    Sheets("sheet1").Range("F" & lastcell+1)=textbox6.text
    Sheets("sheet1").Range("G" & lastcell+1)=textbox7.text
    Sheets("sheet1").Range("H" & lastcell+1)=textbox8.text
    Sheets("sheet1").Range("I" & lastcell+1)=textbox9.text
    (Expand as necessary).

    If you are using comboboxes (dropdowns), subsitute combobox(number).value for textbox(number).text
    You can change "Sheet1" for whatever the sheet name is.

    Should get you started.
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
  • Lifeisbutadream
    Lifeisbutadream Posts: 13,102 Forumite
    rmg1 wrote: »
    First, a couple of assumptions.
    1) the data is going onto a sheet named "Sheet1"
    2) there is a save button on the userform

    In the code for the save button, you'll need something like :-
    lastcell=Sheets("sheet1").range("A65536").end(xlup)
    Sheets("sheet1").Range("A" & lastcell+1)=textbox1.text
    Sheets("sheet1").Range("B" & lastcell+1)=textbox2.text
    Sheets("sheet1").Range("C" & lastcell+1)=textbox3.text
    Sheets("sheet1").Range("D" & lastcell+1)=textbox4.text
    Sheets("sheet1").Range("E" & lastcell+1)=textbox5.text
    Sheets("sheet1").Range("F" & lastcell+1)=textbox6.text
    Sheets("sheet1").Range("G" & lastcell+1)=textbox7.text
    Sheets("sheet1").Range("H" & lastcell+1)=textbox8.text
    Sheets("sheet1").Range("I" & lastcell+1)=textbox9.text
    (Expand as necessary).

    If you are using comboboxes (dropdowns), subsitute combobox(number).value for textbox(number).text
    You can change "Sheet1" for whatever the sheet name is.

    Should get you started.


    Thank you so much.

    I used to just copy old formulas, but I have since bought a new PC and didnt transfer all my documents over.

    Very impressivly quick answer by the way!
  • rmg1
    rmg1 Posts: 3,159
    Part of the Furniture 1,000 Posts Name Dropper
    Forumite
    Just nice timing, and the fact that I've literally just finished doing something similar for the bods here at work. :j
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
This discussion has been closed.
★ ★ ★ Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 355.9K Banking & Borrowing
  • 255K Reduce Debt & Boost Income
  • 456.2K Spending & Discounts
  • 248.4K Work, Benefits & Business
  • 606.1K Mortgages, Homes & Bills
  • 179K Life & Family
  • 263.9K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.2K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.