jon_vaughan
New Member
- Joined
- Mar 10, 2013
- Messages
- 5
Hello,
I am having issues with a macro using Excel 2003. The end goal of the macro is to validate an on-site inventory of boxes. Some information about workbook:
The macro is supposed to first have an Input Box pop-up where you enter a manual count of the boxes, and then compare that manual count against the number of boxes entered into the inventory. However even if cells A1 and B1 are equal, and cell C1 says "TRUE", I still get the message box "Error!", when that is only supposed to pop-up if the values in A1 and B1 are not equal. Is this because I have a formula in cell C1? How would I fix this? The macro code is below.
Thanks.
Sub OnSite_Validation()
Sheets("On-Site Inventory").Select
Range("A1").Select
ActiveCell.FormulaR1C1 = InputBox("Number of Physical Boxes")
If Sheets("On-Site Inventory").Range("C1").Value = "TRUE" Then
Sheets("MAIN").Select
MsgBox ("On-Site Inventory Validated!")
End If
Sheets("MAIN").Select
MsgBox ("Error!")
End Sub
I am having issues with a macro using Excel 2003. The end goal of the macro is to validate an on-site inventory of boxes. Some information about workbook:
- the button triggering the macro is on the worksheet "MAIN"
- on the worksheet "On-Site Inventory" there is a count formula in cell B1 that counts the number of boxes entered into the inventory =counta(B3:B2000)
- on the worksheet "On-Site Inventory" there is an IF formula in cell C1 that =if(A1=B1,TRUE)
The macro is supposed to first have an Input Box pop-up where you enter a manual count of the boxes, and then compare that manual count against the number of boxes entered into the inventory. However even if cells A1 and B1 are equal, and cell C1 says "TRUE", I still get the message box "Error!", when that is only supposed to pop-up if the values in A1 and B1 are not equal. Is this because I have a formula in cell C1? How would I fix this? The macro code is below.
Thanks.
Sub OnSite_Validation()
Sheets("On-Site Inventory").Select
Range("A1").Select
ActiveCell.FormulaR1C1 = InputBox("Number of Physical Boxes")
If Sheets("On-Site Inventory").Range("C1").Value = "TRUE" Then
Sheets("MAIN").Select
MsgBox ("On-Site Inventory Validated!")
End If
Sheets("MAIN").Select
MsgBox ("Error!")
End Sub