JeremyA1976
Board Regular
- Joined
- Aug 3, 2015
- Messages
- 59
I have the following code that updates my inventory sheet with new totals. The problem is, when I enter something in that does not show up on the inventory sheet, I get an error message and when I debug, it points to the section of code shown below. My question is how to add an if statement to the loop that would check to see if H2 = #N/A, and if it does, to have it skip to deleting the row instead of searching the inventory (basically, if its miscellaneous material, and not on inventory, it just deletes row 2 from the LOGCOUNT sheet and moves on with the code)
Is this possible?
Is this possible?
Code:
Sub ProcessOut()
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim wb3 As Workbook
Set wb1 = Workbooks("Charge Out Template.xlsm")
Set wb2 = Workbooks("Charge Out Log.xlsm")
Set wb3 = Workbooks("Inventory Sheet.xlsm")
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim ws3 As Worksheet
Dim ws4 As Worksheet
Set ws1 = wb1.Sheets("CHARGE OUT FORM")
Set ws2 = wb2.Sheets("CHARGE OUT LOG")
Set ws3 = wb3.Sheets("INVENTORY")
Set ws4 = wb1.Sheets("LOGCOUNT")
Set ws5 = wb3.Sheets("Inventory Backup")
'more code above but not part of issue
'COPY FROM TEMPLATE "LOGCOUNT" TO INVENTORY
'FIRST ROW ENTER START
'LOOP
Do While Len(ws4.Range("A2").Value) > 0
ws4.Activate
ActiveSheet.Range("G2").Select
Selection.Copy
ws3.Activate
ActiveSheet.Range("AC1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ws4.Activate
ActiveSheet.Range("H2").Select
Selection.Copy
ws3.Activate
ActiveSheet.Range(Range("AC1").Value).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ws4.Activate
ActiveSheet.Rows([2]).EntireRow.Delete
Loop
'there is more code below, but has nothing to do with the problem
End Sub