The following VBA code is giving me false outcomes: Public Sub CopyServiceSchedules()…
- User
The following VBA code is giving me false outcomes: Public Sub CopyServiceSchedules() Dim xWs As Worksheet Dim xCWs As Worksheet Dim Xrg As Range Dim xStrName As String Dim xRStr As String Dim xRRg As Range Dim xC As Integer Dim wsName As String On Error Resume Next Worksheets("SrvSrch").Visible = True Worksheets("SrvSrch").Range("A1:K201").ClearContents Application.DisplayAlerts = False xStr = "SrvSrch" xRStr = "Service" Set xCWs = ActiveWorkbook.Worksheets.Item(xStr) If xCWs Is Nothing Then Set xCWs = ActiveWorkbook.Worksheets.Add xCWs.Name = xStr End If xC = 1 For Each xWs In ActiveWorkbook.Worksheets wsName = xWs.Name If Len(wsName) = 3 Then Set Xrg = xWs.Range("B:B") Set Xrg = Intersect(Xrg, xWs.UsedRange) For Each xRRg In Xrg If xRRg.Value = xRStr Then xWs.Range(xRRg.Offset(0, -1), xRRg.Offset(0, 9)).Copy xCWs.Cells(xC, 1).PasteSpecial xlPasteValuesAndNumberFormats xC = xC + 1 End If Next xRRg End If Next xWs Application.CutCopyMode = False Application.DisplayAlerts = True Worksheets("SrvSrch").Visible = False Application.CutCopyMode = True End Sub
- Assistant
This VBA code copies service schedules from various worksheets in the active workbook to a new worksheet named "SrvSrch". However, you mentioned that it is giving you false outcomes. To help troubleshoot the issue, can you provide more information about the false outcomes you are experiencing?