+ Reply to Thread
Results 1 to 9 of 9

Poplating a cell from a form

Hybrid View

ewan1979 Poplating a cell from a form 08-17-2011, 07:01 AM
Steffen Thomsen Re: Poplating a cell from a... 08-17-2011, 07:06 AM
ewan1979 Re: Poplating a cell from a... 08-17-2011, 07:30 AM
Steffen Thomsen Re: Poplating a cell from a... 08-17-2011, 07:35 AM
ewan1979 Re: Poplating a cell from a... 08-17-2011, 07:47 AM
royUK Re: Poplating a cell from a... 08-17-2011, 07:58 AM
royUK Re: Poplating a cell from a... 08-19-2011, 02:08 AM
  1. #1
    Registered User
    Join Date
    08-12-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    17

    Poplating a cell from a form

    Hi All,

    I am trying to poplate a cell on the spreadsheet from a form.

    The workseet is called Master and the form is called orderForm. I am trying to populate the cell(9,1) with the text box customerInput on the form with the code below, but I get the error 'Subscript out of range'. Could anyone assist?


    PHP Code: 
    Private Sub submitOrder_Click()

    Worksheets(Master).Cells(91).Value customerInput

    End Sub 

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Poplating a cell from a form

    Just change to this:

    your textbox has a number on the userform, you can use this to specify wich textbox's value you insert.

    
    Private Sub submitOrder_Click() 
    
    Worksheets("Master").Cells(9, 1).Value = TextBox1.value ' asuming it's the only texybox on the userform
    
    End Sub

  3. #3
    Registered User
    Join Date
    08-12-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Poplating a cell from a form

    Thanks Steffen, this has worked in part. I do have other variables to populate the row as per the code below. However when it update cell(9, 1) with customer input, it then reverts to Worksheet_Change(ByVal Target As Range) event and does not populate the spreadsheet with the remaining variables. Do you know whyit is going to the worksheet change event?


    Private Sub submitOrder_Click()

    Worksheets("Master").Cells(9, 1).Value = customerInput.Value
    Worksheets("Master").Cells(9, 2).Value = TextBox1.Value
    Worksheets("Master").Cells(9, 3).Value = TextBox2.Value
    Worksheets("Master").Cells(9, 4).Value = TextBox3.Value
    Worksheets("Master").Cells(9, 5).Value = TextBox4.Value
    Worksheets("Master").Cells(9, 6).Value = TextBox5.Value
    Worksheets("Master").Cells(9, 7).Value = TextBox6.Value


    End Sub




    Private Sub Worksheet_Change(ByVal Target As Range)

    End Sub

  4. #4
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Poplating a cell from a form

    Hi,

    Remember to put code tags around your code.

    Can you post a dumme workbook with your code?

    Steffen Thomsen

  5. #5
    Registered User
    Join Date
    08-12-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Poplating a cell from a form

    Quote Originally Posted by Steffen Thomsen View Post
    Hi,

    Remember to put code tags around your code.

    Can you post a dumme workbook with your code?

    Steffen Thomsen


    Thanks for this Steffen. Whe you open up the worksheet there is an Enter Order button on the top right. This displays the order form then you just press 'Submit Order'.
    Last edited by royUK; 08-19-2011 at 02:09 AM.

  6. #6
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Poplating a cell from a form

    Hi,

    It works fine with me.

    Maby just add this before end sub

    
    Unload me
    Steffen Thomsen

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Poplating a cell from a form

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Poplating a cell from a form

    Your post does not comply with Rule 7 of our Forum RULES. Please do not ignore Moderators' or Administrators' requests - note that this includes requests by senior members as well, if you are unclear about their request or instruction then send a private message to them asking for help. Do not post a reply to a thread where a moderator has requested an action that has not been complied with e.g Title change or Code tags...etc

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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