kcanbarasu
New Member
- Joined
- Mar 3, 2020
- Messages
- 5
- Office Version
- 2016
- Platform
- Windows
Hi There,
i have created one VBA macro to pull all the information from other sheet and copied into the new sheet where VBA macro used. This macro works fine if i execute it in my local drive (C:\). If i copy this macro into network drive, it is not working fine.
The VBA Code is as below.
Sub CombineFiles()
Dim Path As String
Dim FileName As String
Dim Wkb As Workbook
Dim ws As Worksheet
Application.EnableEvents = False
Application.ScreenUpdating = False
macrowkb = ThisWorkbook.Name
Path = ThisWorkbook.Worksheets("Macro").Range("D5").Value
If Path <> "" Then
FileName = Dir(Path & "\*.xls", vbNormal)
Do Until FileName = ""
Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
ActiveSheet.AutoFilterMode = False
Range("F3:F14").Copy
ThisWorkbook.Activate
Sheets("TrackerSheet").Select
ActiveSheet.AutoFilterMode = False
lr = Range("a1048576").End(xlUp).Row
Cells(lr + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
Wkb.Activate
Wkb.Close False
FileName = Dir()
Loop
End If
ThisWorkbook.Activate
Sheets("TrackerSheet").Select
Range("N:N").Clear
Range("N2").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-11],RC[-11])"
ActiveCell.Copy
lr = Range("a1048576").End(xlUp).Row
Range("N3:N" & lr).PasteSpecial xlPasteFormulas
Application.CutCopyMode = False
For Each aCell In Range("N2:N" & lr)
If aCell.Value > 1 Then
Range("L" & aCell.Row).Value = "Duplicate. Please check"
End If
Next
Range("M:M").Clear
Cells.Select
Application.CutCopyMode = False
With Selection.Font
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
Sub Excel_Input_File_1()
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = Application.DefaultFilePath
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With
NextCode:
ThisWorkbook.Worksheets("Macro").Range("D5").Value = sItem
Set fldr = Nothing
End Sub
Sub test()
'For Each ws In Wkb.Worksheets
'ActiveSheet.AutoFilterMode = False
'Range("F4:F10").Select
'Range("L1").Value = "Check"
'Range("L2").Select
'ActiveCell.FormulaR1C1 = "=COUNTIF([" & macrowkb & "]TrackSheet!C6,RC[-6])"
'Selection.Copy
'lr = Range("a1048576").End(xlUp).Row
'Range("L3:L" & lr).PasteSpecial xlPasteFormulas
'Selection.Copyx
'Application.CutCopyMode = False
'Range("a1").Select
'Range("a1:l" & lr).AutoFilter Field:=12, Criteria1:="0"
'If Range("a1048576").End(xlUp).Row <> 1 Then
'lr = Range("a1048576").End(xlUp).Row
'Range("a2:j" & lr).SpecialCells(xlCellTypeVisible).Copy
'End If
'Range("F4:F10").Copy
'ws.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
'Next ws
End Sub
Please help to fix this issue?
Thanks,
Anbu
i have created one VBA macro to pull all the information from other sheet and copied into the new sheet where VBA macro used. This macro works fine if i execute it in my local drive (C:\). If i copy this macro into network drive, it is not working fine.
The VBA Code is as below.
Sub CombineFiles()
Dim Path As String
Dim FileName As String
Dim Wkb As Workbook
Dim ws As Worksheet
Application.EnableEvents = False
Application.ScreenUpdating = False
macrowkb = ThisWorkbook.Name
Path = ThisWorkbook.Worksheets("Macro").Range("D5").Value
If Path <> "" Then
FileName = Dir(Path & "\*.xls", vbNormal)
Do Until FileName = ""
Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
ActiveSheet.AutoFilterMode = False
Range("F3:F14").Copy
ThisWorkbook.Activate
Sheets("TrackerSheet").Select
ActiveSheet.AutoFilterMode = False
lr = Range("a1048576").End(xlUp).Row
Cells(lr + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
Wkb.Activate
Wkb.Close False
FileName = Dir()
Loop
End If
ThisWorkbook.Activate
Sheets("TrackerSheet").Select
Range("N:N").Clear
Range("N2").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(C[-11],RC[-11])"
ActiveCell.Copy
lr = Range("a1048576").End(xlUp).Row
Range("N3:N" & lr).PasteSpecial xlPasteFormulas
Application.CutCopyMode = False
For Each aCell In Range("N2:N" & lr)
If aCell.Value > 1 Then
Range("L" & aCell.Row).Value = "Duplicate. Please check"
End If
Next
Range("M:M").Clear
Cells.Select
Application.CutCopyMode = False
With Selection.Font
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
Sub Excel_Input_File_1()
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = Application.DefaultFilePath
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With
NextCode:
ThisWorkbook.Worksheets("Macro").Range("D5").Value = sItem
Set fldr = Nothing
End Sub
Sub test()
'For Each ws In Wkb.Worksheets
'ActiveSheet.AutoFilterMode = False
'Range("F4:F10").Select
'Range("L1").Value = "Check"
'Range("L2").Select
'ActiveCell.FormulaR1C1 = "=COUNTIF([" & macrowkb & "]TrackSheet!C6,RC[-6])"
'Selection.Copy
'lr = Range("a1048576").End(xlUp).Row
'Range("L3:L" & lr).PasteSpecial xlPasteFormulas
'Selection.Copyx
'Application.CutCopyMode = False
'Range("a1").Select
'Range("a1:l" & lr).AutoFilter Field:=12, Criteria1:="0"
'If Range("a1048576").End(xlUp).Row <> 1 Then
'lr = Range("a1048576").End(xlUp).Row
'Range("a2:j" & lr).SpecialCells(xlCellTypeVisible).Copy
'End If
'Range("F4:F10").Copy
'ws.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
'Next ws
End Sub
Please help to fix this issue?
Thanks,
Anbu