Results 1 to 7 of 7

UserForm textbox save loop anomaly

Threaded View

  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.

    Private Sub CommandButton5_Click()
    
    Dim CC As Control
    Application.DisplayAlerts = False
        For Each CC In Me.Controls
            If TypeName(CC) = "TextBox" Then
                    If CC.Value = "" Then
                    MsgBox "Please select the " & CC.Tag
                    Exit Sub
                    End If
            End If
        Next CC
        On Error Resume Next
        For Each CC In Me.Controls
            Workbooks.Open CC.Value
            ActiveWorkbook.SaveAs Filename:=Environ("TMP") & "\" & CC.Tag & ".xlsx"
        Next CC
    Unload Me
    Workbooks.Add
    ActiveWorkbook.SaveAs Filename:=Environ("TMP") & "\" & TextBox5.Value & ".xlsx"
    Application.DisplayAlerts = True
    ThisWorkbook.Close savechanges:=False
    End Sub
    Last edited by radddogg; 11-09-2016 at 06:15 AM. Reason: Solved

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. 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