+ Reply to Thread
Results 1 to 5 of 5

Loop for text box data in USER FORM

  1. #1
    Registered User
    Join Date
    01-03-2011
    Location
    Bangalore, India
    MS-Off Ver
    MS Excel 2010
    Posts
    49

    Loop for text box data in USER FORM

    Hello there,

    I am trying to create a do while loop for the below code on the user form. Not able to execute. In below code Textbox1 has date (i.e FROM Date) this works fine.
    Now I have added another text box TextBox3 which will have (TO date). I want the do all the steps in the below code for each date i.e FROM date to TO date... eg if FROM date (TextBox1) is 07/01/2015 and To date (TextBox3) is 07/10/2015, I want the data to be copied from form to Excel table in 10 rows (each row for a single date).
    Any thoughts on how loop can be applied for this.

    When I tried to use While loop getting an error message: “Compile Error: NEXT without For”

    Below is the code.

    Please Login or Register  to view this content.
    Thanks!
    H N S

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,667

    Re: Loop for text box data in USER FORM

    You got this error message because you used
    Please Login or Register  to view this content.
    while you shall use
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    01-03-2011
    Location
    Bangalore, India
    MS-Off Ver
    MS Excel 2010
    Posts
    49

    Re: Loop for text box data in USER FORM

    Thank you Kaper.

    Though the macro is working when changed to "Wend" from "Next".
    Not able to get the desired output... eg. if I input in TextBox1 as 07/01/2015 and in TextBox3 as 07/02/2015... I wanted just 2 rows of data to be pasted in sheet i.e 1 row as 07/01/2015 and the 2nd row as 07/02/2015.
    But the macro is pasting the single date 07/01/2015 for 29 rows...

    Any thoughts. I know I am asking too much Sir, but have struck in this from past 40+ hours.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,667

    Re: Loop for text box data in USER FORM

    No file so I not played with it.

    Looking at the code I have no idea what is assigned to:
    Please Login or Register  to view this content.
    or to
    Please Login or Register  to view this content.
    and how dates could be written into a sheet while your date is stored in
    Please Login or Register  to view this content.
    but it is never used in any of
    Please Login or Register  to view this content.
    assignments

    so blind guess assuming your declaration that from/to dates atre in textbox1 and 3:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-03-2011
    Location
    Bangalore, India
    MS-Off Ver
    MS Excel 2010
    Posts
    49

    Re: Loop for text box data in USER FORM

    Many Thanks kaper. Based on you r inputs twiked code a bit and it works perfect!!!

+ 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. Data Validation between text boxes on user form
    By batmom2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-05-2015, 03:33 PM
  2. [SOLVED] text box data in a user form copy to a range in sheet 3
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2015, 09:22 AM
  3. Replies: 1
    Last Post: 08-28-2013, 05:04 PM
  4. Can't get User Form to collect data instead of text box
    By Kyle Mead in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-04-2010, 02:16 AM
  5. Serching data using text box in user form
    By jiguvaidya in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2008, 07:36 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