ExcelNUB1234
New Member
- Joined
- Oct 18, 2021
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
- Web
Hello,
I am creating a workbook to track repairs and create a report for a specific client. Each trouble ticket (RMA) get its own sheet with details, I am able to copy the necessary information to the place that I need it for my report, however it is doing this for all worksheets except tabs that I have already specified not to, for example my trouble ticket template, my reports pages and any other page with an actual name. My trouble tickets are named by number in the order I receive them from each client I work with.
The problem is, I need to compile the data into a report for one specific client, I need code that will skip over a certain worksheet that does not contain a specific phrase in cell H17, the phrase being "FAR".
Code is ugly, but functional; any help provided will be much appreciated.
I am creating a workbook to track repairs and create a report for a specific client. Each trouble ticket (RMA) get its own sheet with details, I am able to copy the necessary information to the place that I need it for my report, however it is doing this for all worksheets except tabs that I have already specified not to, for example my trouble ticket template, my reports pages and any other page with an actual name. My trouble tickets are named by number in the order I receive them from each client I work with.
The problem is, I need to compile the data into a report for one specific client, I need code that will skip over a certain worksheet that does not contain a specific phrase in cell H17, the phrase being "FAR".
VBA Code:
Sub CustomerA_Report()
Dim sh As Worksheet
Dim wb As Workbook
Dim DestSh As Worksheet
Dim i As Integer
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set wb = ThisWorkbook
Set DestSh = wb.Sheets("CustomerA")
i = 3
For Each sh In ActiveWorkbook.Worksheets
If sh.Range("E17").Value = "**SPECIFIC PHRASE**" Then
Worksheets(ActiveSheet.Index + 1).Select
End If
If IsError(Application.Match(sh.Name, _
Array(DestSh.Name, "Index", "Lists", "Current Index", "Changes", "CustomerA"), 0)) Then
sh.Range("F4").copy
'RMA#'
With DestSh.Range("A" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Client'
sh.Range("E15").copy
With DestSh.Range("B" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Client Department'
sh.Range("K15").copy
With DestSh.Range("C" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'FAR'
sh.Range("H17").copy
With DestSh.Range("D" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'System SN'
sh.Range("L4").copy
With DestSh.Range("E" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Failed Component'
sh.Range("F6").copy
With DestSh.Range("F" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Failed Component SN'
sh.Range("L6").copy
With DestSh.Range("G" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Date of Report'
sh.Range("Q4").copy
With DestSh.Range("H" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Date of Receipt'
sh.Range("V23").copy
With DestSh.Range("I" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Description of Failure'
sh.Range("H8").copy
With DestSh.Range("J" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Estimated Completion Date'
sh.Range("N36").copy
With DestSh.Range("K" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Diagnostic Start Date'
sh.Range("G10").copy
With DestSh.Range("L" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Diagnostic End Date'
sh.Range("M10").copy
With DestSh.Range("M" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Status'
sh.Range("V4").copy
With DestSh.Range("N" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Date of QA'
sh.Range("N38").copy
With DestSh.Range("O" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Outgoing Tracking #'
sh.Range("F27").copy
With DestSh.Range("P" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Ship Date'
sh.Range("R27").copy
With DestSh.Range("Q" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Warranty'
sh.Range("Q6").copy
With DestSh.Range("R" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Invoice'
sh.Range("V32").copy
With DestSh.Range("S" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
'Service Level'
sh.Range("R10").copy
With DestSh.Range("T" & i)
.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With
i = i + 1
End If
Next
End Sub
Code is ugly, but functional; any help provided will be much appreciated.
Last edited by a moderator: