Hello Everyone,
I have buid a code to pull counts from other files and it takes some time. While to do this i want to show User form and i have added it in my code and it is displaying it. But the problem is Macro is doing the activities twice. and i not getting where i am worng. Please help...
PFA for the same Sample.xls
Sub corefunction()
Application.ScreenUpdating = False
waitform.Show
DoEvents
Shstart.Select
Dim path As Variant
path = Range("C1").value & Range("G1").Text & "\" & Range("H1").Text & "\" & Range("i1").Text & "\"
lastrow = Sheets("start").Cells(Rows.Count, "A").End(xlUp).Row
XLSDirectory = path
Dim Runname As String
Dim Index As String
First = True
Do
If First = True Then
Xlsfilename = Dir(XLSDirectory & "*.xls")
First = False
Else
Xlsfilename = Dir()
End If
If Xlsfilename <> "" Then
Workbooks.Open Filename:=XLSDirectory & Xlsfilename
Set oldbk = ActiveWorkbook
With ThisWorkbook
Dim wbkbname As Variant
wbkname = ActiveWorkbook.Name
Shstart.Activate
Worksheets("Start").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).value = wbkname
oldbk.Activate
Dim ws As Worksheet
For Each ws In Worksheets
ws.Activate
Dim value As Long
Dim shname As Variant
value = Application.WorksheetFunction.CountA(Range("A:A")) - 1
Shstart.Activate
Dim lastrow2 As Long
lastrow2 = Range("A" & Rows.Count).End(xlUp).Row
Range("A" & Rows.Count).End(xlUp).Select
Cells(lastrow2, Columns.Count).End(xlToLeft).Offset(0, 1).Activate
ActiveCell.value = value
oldbk.Activate
Next ws
ActiveWorkbook.Close
End With
End If
Loop While Xlsfilename <> ""
Shstart.Range("A3").Select
waitform.Hide
MsgBox "Macro Completed, Please Review...!", vbInformation, "Developed By : Deepak Sirsale"
End Sub
Bookmarks