So I have a PivotTable being modified via a commandbox inside of a userform. If the user types in a name that isn't in the list, I get the error:
I tried the following:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">OnErrorResumeNext
</code>I was hoping that would simply "skip over" the issue. Nope, that didn't work out haha.
Though ideally I would like to create a custom error message that pops up only one time (instead of 5 times) and tells the user to enter a name from their department/shift. The list (that my commandbox uses) overall has everyone from every shift from every department, but not all people have data in the PivotTable and so just b/c they are on the list my commandbox users, they are not necessarily in the PivotTable. I know that's confusing, but I have to have it that way b/c the same interface is being used by all shifts. I do not have access to the list of people within departments, shifts, etc. I only have a master list of everyone, so that's why my commandbox has to use that.
I'm still "new" to VBA, but I am not new to error handling in general. I know how I would handle this in Java, but not in VBA.
This is the part of code, which fails:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">Range("D2").Select
ActiveCell.Value = frmInd_Productivity_TrackerPS.ComboBox1.Value
ActiveSheet.Range("B1").Select
ActiveCell.Value = Range("F2").Value
</code>
My main problem is that I don't know how to get it to "skip" that error and actually go to the next error? Can you tell me how to do that? In Java, the Try/Catch block automatically goes to the next level after handling the error. I can't get VBA to just "toss out" the error and continue running.
I have 5 PivotTables in total, all of which get modified by the commandbox. So each one of them throws up the error, giving me 5 errors in a row that ask me to rename a person on the pivottable to the name of the person that isn't. B1 is my pivottable filter box. I have to modify the value from the combobox, which is the value that "F2" winds up as. In other words, "F2" is my finished product that is "copied" to the pivottable filter box (I know you can't actually "copy" it there, its just setting the value equal to "F2").
No item of this name exists in the PivotTable report. Rename Name1 to Name2? where <code style="color: rgb(34, 36, 38); margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);">Name1</code> is a person on the list and <code style="color: rgb(34, 36, 38); margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);">Name2</code> is a person not on the list.
I actually get this error like 5 times b/c of the number of PivotTables my commandbox modifies.I tried the following:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">OnErrorResumeNext
</code>I was hoping that would simply "skip over" the issue. Nope, that didn't work out haha.
Though ideally I would like to create a custom error message that pops up only one time (instead of 5 times) and tells the user to enter a name from their department/shift. The list (that my commandbox uses) overall has everyone from every shift from every department, but not all people have data in the PivotTable and so just b/c they are on the list my commandbox users, they are not necessarily in the PivotTable. I know that's confusing, but I have to have it that way b/c the same interface is being used by all shifts. I do not have access to the list of people within departments, shifts, etc. I only have a master list of everyone, so that's why my commandbox has to use that.
I'm still "new" to VBA, but I am not new to error handling in general. I know how I would handle this in Java, but not in VBA.
This is the part of code, which fails:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">Range("D2").Select
ActiveCell.Value = frmInd_Productivity_TrackerPS.ComboBox1.Value
ActiveSheet.Range("B1").Select
ActiveCell.Value = Range("F2").Value
</code>
My main problem is that I don't know how to get it to "skip" that error and actually go to the next error? Can you tell me how to do that? In Java, the Try/Catch block automatically goes to the next level after handling the error. I can't get VBA to just "toss out" the error and continue running.
I have 5 PivotTables in total, all of which get modified by the commandbox. So each one of them throws up the error, giving me 5 errors in a row that ask me to rename a person on the pivottable to the name of the person that isn't. B1 is my pivottable filter box. I have to modify the value from the combobox, which is the value that "F2" winds up as. In other words, "F2" is my finished product that is "copied" to the pivottable filter box (I know you can't actually "copy" it there, its just setting the value equal to "F2").