Hi

Replace the commandbutton1 code with this one.

Private Sub CommandButton1_Click()
    Dim wbkActive   As Workbook
    Dim FilePath    As String
    Dim FileName    As String
    Dim wbkOpen     As Workbook
    Dim LastRow     As Long

    If wbkActive Is Nothing Then Set wbkActive = ThisWorkbook

    FilePath = "C:\Users\Indra\Desktop\"
    If Right(FilePath, 1) <> "\" Then FilePath = FilePath & "\"

    If Len(Me.TextBox1.Value) Then
        If Len(Me.TextBox2.Value) Then
            If Len(Me.TextBox3.Value) Then
                FileName = FilePath & Me.TextBox3.Value & ".xlsx"
                Dim r
                r = Evaluate("match(""" & Me.TextBox3.Value &
""",'MasterSheet'!B4:B1000,0)")

                If Not FileIsOpen(FileName) Then
                    Set wbkOpen = Workbooks.Open(FilePath &
Me.TextBox3.Value & ".xlsx")
                    With wbkOpen.Worksheets(1)
                        LastRow = .Range("b" & .Rows.Count).End(3).Row + 1
                        .Range("a" & LastRow) = LastRow - 3
                        .Range("b" & LastRow).Resize(, 3) =
Split(Me.TextBox2.Value & "," & Me.TextBox1.Value & "," &
Me.TextBox3.Value, ",")
                    End With
                    wbkOpen.Close 1
                    Set wbkOpen = Nothing
                    MsgBox "Done", , "ExcelFox.com"
                    Unload Me
                    If Not IsError(r) Then
                        Cells(r, "f") = "Assigned"
                    End If
                Else
                    MsgBox "Workbook '" & FileName & "' is already
opened" & vbLf & "Close the workbook and try again", vbInformation,
"ExcelFox.com"
                    If Not IsError(r) Then
                        Cells(r, "f") = "Unassigned"
                    End If
                    Exit Sub
                End If
            Else
                MsgBox "Emp ID is missing", vbInformation, "ExcelFox.com"
                Me.TextBox3.SetFocus
            End If
        Else
            MsgBox "Batch No is missing", vbInformation, "ExcelFox.com"
            Me.TextBox2.SetFocus
        End If
    Else
        MsgBox "Site is missing", vbInformation, "ExcelFox.com"
        Me.TextBox1.SetFocus
    End If
End Sub


> 1. Through this Master file I'm able to create the slave files, but it's not
> opening, showing an error "invalid format".

I'm not sure how you create the slave files. So I can't comment on that.

> 3. In the Master file "Batch Assign to" and "Batch Status" is not updating
> after assigning any Batch to the slave file.

See the code above.

Kris
ExcelFox

-- 
Join official facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES (1120+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

6) Jobs posting is not allowed.

7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to 
excel-macros+unsubscr...@googlegroups.com.


Reply via email to