Consulting

Results 1 to 11 of 11

Thread: Solved: populating a worksheet

  1. #1

    Lightbulb Solved: populating a worksheet

    there are different input forms with which user input different data. I want to save all data together in a worksheet. So for each form I need one column in a worksheet. what are the codes to make clear which column is empty. I mean from A to Z and ... . So the first data will be saved in column A and then when A is full it will go to B and so on.

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Maryam,
    I don't know if it will help or not but attached is an example of a simple data input form using textboxes. I think it would be easier to upload it than to try to explain how to insert a form and add the textboxes and code. Mostly look at the code for the userform button click event. Should get you started and comboxes, etc. can be used. Hope this helps.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    can we change the codes for last column. I want to save in columns.

  4. #4
    How to change these for column?
    Dim LastRow As Object
    Set LastRow = Sheet1.Range("a65536").End(xlUp)
    LastRow.Offset(1, 0).Value = TextBox1.Text
    LastRow.Offset(1, 1).Value = TextBox2.Text
    LastRow.Offset(1, 2).Value = TextBox3.Text

    IV is the last column, but when i replace a65536 with IV is gives debug!

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA] Set LastColumn = Sheet1.Range("IV1").End(xlToleft)[/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    yes.
    Set LastRow = Sheet1.Range("IV1").End(xlToLeft)

    LastRow.Offset(0, 1).Value = TextBox1.Text
    LastRow.Offset(1, 1).Value = TextBox2.Text
    LastRow.Offset(2, 1).Value = TextBox3.Text

    Thank you

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Maryam,
    Using a variable called LastRow to refer to columns looks like a recipe for disaster!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Maryam,
    I agree with Malcolm. Since you have changed from rows to columns you should change your variable in your code from lastrow to lastcolumn or something simialar. Just do a find and replace on the sub.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #9
    lol! sorry. Yes:
    [VBA]
    Set LastColumn = Sheet1.Range("IV1").End(xlToLeft)

    LastColumn.Offset(0, 1).Value = TextBox1.Text
    LastColumn.Offset(1, 1).Value = TextBox2.Text
    LastColumn.Offset(2, 1).Value = TextBox3.Text
    [/VBA]
    Edit by Lucas: code tags added

  10. #10
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Be sure to mark your thread solved Maryam using the thread tools at the top of the page. You can select your code and hit the button marked VBA to make your post look like it does in the vbe like Malcolms code in post #5 of this thread.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  11. #11
    VBAX Newbie
    Joined
    Mar 2007
    Posts
    1
    Location
    Thank you guys this is just what I was looking for....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •