+ Reply to Thread
Results 1 to 7 of 7

UserForm textbox save loop anomaly

  1. #1
    Forum Contributor
    Join Date
    10-25-2011
    Location
    Preston, England
    MS-Off Ver
    Excel 2016
    Posts
    136

    UserForm textbox save loop anomaly

    Hi all,

    I'm hoping someone can point out why my userform is behaving oddly.

    I have a userform with 5 command buttons and 5 text boxes. Each textbox has a unique 'tag' property which is used in the code. Buttons 1 to 4 fire the file dialog for the user to select a raw data excel file and puts the filepath into the corresponding textbox. CommandButton5 contains code which opens these filepaths. TextBox5 is a free text entry where the user can choose the project name. The code for CommandButton5 is below. Basically the form is supposed to get the user to select the 4 data files, open the files, save a temporary file with a filename of the textbox 'tag', open a blank workbook and save it with the filename of TextBox5.Value.

    This all works perfectly except the file opened by TextBox4 is saved with the 'tag' property from TextBox5 and I have no idea why. Any ideas? thanks

    I'd also appreciate any tips regarding anything I may have missed out of my code or any noob errors I've made.

    Please Login or Register  to view this content.
    Last edited by radddogg; 11-09-2016 at 06:15 AM. Reason: Solved

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: UserForm tag anomaly

    By the looks of it, its saving Workbook 4 twice. Once correctly and then again with the TextBox5 value.

    Although you open a blank workbook before textbox 5 action you dont tell Excel to save that one as the textbox5 one, you tell it to save the ActiveWorkbook
    If someone has helped you then please add to their Reputation

  3. #3
    Forum Contributor
    Join Date
    10-25-2011
    Location
    Preston, England
    MS-Off Ver
    Excel 2016
    Posts
    136

    Re: UserForm tag anomaly

    Quote Originally Posted by pjwhitfield View Post
    By the looks of it, its saving Workbook 4 twice. Once correctly and then again with the TextBox5 value.

    Although you open a blank workbook before textbox 5 action you dont tell Excel to save that one as the textbox5 one, you tell it to save the ActiveWorkbook
    Thanks for the reply. Hmm. I'm a little confused. Firstly, where in the code are you seeing that it is saving book4 twice? Secondly, why wouldn't the recently added workbook be the activeworkbook, and how can I make it active or at least save it correctly? Cheers

  4. #4
    Forum Contributor
    Join Date
    10-25-2011
    Location
    Preston, England
    MS-Off Ver
    Excel 2016
    Posts
    136

    Re: UserForm tag anomaly

    Quote Originally Posted by pjwhitfield View Post
    By the looks of it, its saving Workbook 4 twice. Once correctly and then again with the TextBox5 value.

    Although you open a blank workbook before textbox 5 action you dont tell Excel to save that one as the textbox5 one, you tell it to save the ActiveWorkbook
    Ah I get it!

    TB5 is just a filename rather than a file path so it was throwing a file can't be found error. I added the error handler to skip opening that 'file' but the save action still happens. I get it.

    So how to get round it? Maybe using a combobox instead but not very elegant. Hmm, will have a think.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: UserForm tag anomaly

    Perhaps thus
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Forum Contributor
    Join Date
    10-25-2011
    Location
    Preston, England
    MS-Off Ver
    Excel 2016
    Posts
    136

    Re: UserForm tag anomaly

    Quote Originally Posted by xlnitwit View Post
    Perhaps thus
    Please Login or Register  to view this content.
    Beautiful, thanks so much!

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: UserForm textbox save loop anomaly

    You're welcome.

+ 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. [SOLVED] Formula anomaly
    By Mulpuzzle in forum Excel Formulas & Functions
    Replies: 30
    Last Post: 07-29-2016, 12:14 AM
  2. [SOLVED] round up/down anomaly?
    By thesurfer in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-22-2015, 04:28 PM
  3. IF function anomaly
    By BBS in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-07-2007, 11:51 AM
  4. DATEDIF anomaly?
    By cruisy in forum Excel General
    Replies: 5
    Last Post: 05-25-2007, 12:10 AM
  5. Printing Anomaly
    By Otto Moehrbach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-26-2005, 11:05 AM
  6. [SOLVED] Formatting Anomaly
    By Christopher Weaver in forum Excel General
    Replies: 2
    Last Post: 05-13-2005, 06:06 PM
  7. [SOLVED] VLOOKUP Anomaly
    By Tosca in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-08-2005, 05:08 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