+ Reply to Thread
Results 1 to 18 of 18

Facing problem while saving data in desired cell in excel sheet from your form

  1. #1
    Registered User
    Join Date
    10-23-2013
    Location
    Punjab, India
    MS-Off Ver
    Excel 2010
    Posts
    10

    Facing problem while saving data in desired cell in excel sheet from your form

    i am new in VBA excel programming, i made a form to save marks obtained by the students in exams. While saving these marks i need to save these marks subject wise and between 2 subjects i need 3 rows to calculate total, percentage and grade. Program working fine till here and data goes in their given cells, but when i enter record of second student instead of going to next row this data goes to the same row, and over write the previous data, so i am facing problem in saving the next record in next row, But if i remove the 3 cells which i leave blank to calculate total, percentage and grade, then there is no problem in saving data in next row, so the problem lies in saving data while leaving 3 columns blank in 2 subject and finding new row, i am also attaching the file. So plz help me to find the solution for this problem. Thanks.
    Attached Files Attached Files

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Try this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hi, Harmeet Singh,

    i stands for Integer, and irow should be of Type Integer according to the prefix, not Long. Why use a With-Statement for the worksheet and preceed any range with the worksheet object?

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    10-23-2013
    Location
    Punjab, India
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Dear xladept ,
    First of all thank you so much my friend for helping me, well i am using same code in my programming, it is saving data where i want but it is not saving new record in next row, its replacing the data saved earlier in same row! but if i am not leaving 2 cells blank in the row and save data in continues cells, then it save the next record in new line!
    Last edited by Harmeet Singh; 11-18-2013 at 12:11 PM.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hi Hameet,

    Maybe:
    Please Login or Register  to view this content.
    But if Column B is one of your blanks cells, then use another column for your next row determination

  6. #6
    Registered User
    Join Date
    10-23-2013
    Location
    Punjab, India
    MS-Off Ver
    Excel 2010
    Posts
    10

    Unhappy Re: Facing problem while saving data in desired cell in excel sheet from your form

    I have tried the other method you asked me to try in second time, but still its not saving the data to a new line!

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hi, Harmeet Singh,

    maybe give this code a try:
    Please Login or Register  to view this content.
    You could insert commands to fill the cells with the formulae in the code (or Autofill to the next row).

    Ciao,
    Holger

  8. #8
    Registered User
    Join Date
    10-23-2013
    Location
    Punjab, India
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hello Holger, Thanks for you time and support, i am going to try it and will give you feed back soon!

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hi, Harmeet Singh,

    seems to be an odd day for me - lHelp isnīt the same as lngHelp
    Please Login or Register  to view this content.
    Ciao,
    Holger

  10. #10
    Registered User
    Join Date
    10-23-2013
    Location
    Punjab, India
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hello holgar, thanks for unconditional support. I want to ask you few more things, do you have a Facebook account or yahoo messenger? So that I can chat with you directly?

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hi, Harmeet Singh,

    neither nor. And I havenīt used my Skype Account for years either. Plus Iīm not at home for the time being. But you may ask here at any time.

    Ciao,
    Holger

  12. #12
    Registered User
    Join Date
    10-23-2013
    Location
    Punjab, India
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hello Holger, sorry for disturbing you again, i was trying to insert the code given by you in my code but was not successful. So i am pasting my code here, will you plz add you code in my code? Thanks you so much

    Harmeet
    Last edited by Harmeet Singh; 11-20-2013 at 07:03 AM.

  13. #13
    Registered User
    Join Date
    10-23-2013
    Location
    Punjab, India
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hello holger,
    Thanks so much for you help, i applied the first code (sample given below) you sent me in my program and it start saving data in new row and also leaving 2 columns blank as i want.

    This code was for 2 subjects, but now i need to add 5 more subjects in it, means after every 3 columns i need two blank columns, so how can i do this, i am also trying at my level, but i will be very thankful to you if you help me in this.

    regards
    Harmeet

    This is the program which is working
    Please Login or Register  to view this content.
    Last edited by Harmeet Singh; 11-20-2013 at 07:04 AM.

  14. #14
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hi, Harmeet Singh,

    you would need to wrap your procedures with code-tags as requested in Forum Rule #3 before anybody should answer your questions.

    Ciao,
    Holger

  15. #15
    Registered User
    Join Date
    10-23-2013
    Location
    Punjab, India
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hello Holger,

    Warped the procedure in code-tags. So will you please tell me how i cam make it working for 5 subjects like i mentioned in previous post?

    Regards,
    Harmeet

  16. #16
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hi, Harmeet Singh,

    the old code looked like
    Please Login or Register  to view this content.
    You would need to add the additional TextBoxes in order to avoid a run-time error (maybe use Format to show leading zeros). The altered code may look like
    Please Login or Register  to view this content.
    Ciao,
    Holger

  17. #17
    Registered User
    Join Date
    10-23-2013
    Location
    Punjab, India
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Book2.xlsm well i made this program to save data in desired cells where i want it, with the help of very kind a nice persons's help, but it is giving me a little error when i am running this program, i am attaching the code here, plz help me to remove this error!
    Last edited by Harmeet Singh; 11-23-2013 at 03:03 AM.

  18. #18
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Facing problem while saving data in desired cell in excel sheet from your form

    Hi, Harmeet Singh,

    your code runs a loop from 1 to 23 while the highest number of the textboxes on the UF is 13 - not so surprising that a run-time error is raised when Textbox14 isnīt found.

    Code behind the UserForm:
    Please Login or Register  to view this content.
    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Hi Guys, am facing problem while doing some excel calculations
    By navneetvyas in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-25-2013, 04:57 AM
  2. [SOLVED] EXCEL USER FORM- data not saving to sheet 3
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2013, 01:27 PM
  3. [SOLVED] Facing Problem with VBA Excel on Pulling data
    By nitesh_greatie in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 04-17-2013, 03:05 AM
  4. Replies: 1
    Last Post: 11-13-2012, 02:06 PM
  5. Facing problem in excel while copying data from one sheet to another sheet
    By krasathi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-03-2012, 04:40 AM

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