VBA Macro not working in network drive.

kcanbarasu

New Member
Joined
Mar 3, 2020
Messages
5
Office Version
  1. 2016
Platform
  1. 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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
dont use drive letters for network paths, f:\folder\folder\file.xls
some folks dont have that letter mapped.

instead always use UNC paths with the full server name....
\\myserver\folder\folder\file.xls
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top