I have a work book with 4 tabs - Raw Data, Install, Early Failure and Reliability. I'm very new with macros, but with the help of the interwebs I was able to put together a macro which did what I wanted....at least on the first tab. Specifically, I needed it to pull out the specific category of data and put it in its respective tab. I created a command button to use. It worked perfectly on the Install tab, but I got an error when I tried it on the other tab. The only thing that changed in the code from tab to tab is the name of the worksheet (Install v. Early Failure v. Reliability). Everything else is exactly the same.
Here is the code:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
a = Worksheets("Raw Data").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("Raw Data").Cells(i, 19).Value = "Repair" And Worksheets("Raw Data").Cells(i, 42).Value = "YES" Then
Worksheets("Raw Data").Rows(i).Copy
Worksheets("Early Failure").Activate
b = Worksheets("Early Failure").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Early Failure").Cells(b + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Worksheets("Raw Data").Activate
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("Raw Data").Cells(1, 1).Select
Application.ScreenUpdating = True
End Sub
When I clicked the Command Button on both the Early Failure and Reliability tabs I got this:
Capture.PNG
When I click to Debug it highlights the line in blue above. It does this for both the Early Failure and Reliability tabs.
I've already tried a couple things:
- Removing the line
- Removing the line and removing the "Worksheets("Raw Data").Activate" line
- Separating it into two lines:ThisWorkbook.Worksheets("Raw Data").Select
Cells(1, 1).Select
- Separating it into two lines and changing the second line:ThisWorkbook.Worksheets("Raw Data").Select
Range("A1").Select
None of these worked, and once I tried the last two, exited Design Mode and tried clicking the Command Buttons on each sheet...nothing happened. The macro didn't run and I didn't get an error.
Any help would be really appreciated! Like I said, I'm very new to macros, so I'm sure it's something super simple.
Thanks!!!!
Amy
Bookmarks