New Member
May 20, 2020
An Excel file has a hand-counted inventory list of drugs: Name, Dosage, Strength, PackageSize, and PackageQty.
The pharmacist batch scans into a SQLExpress Medical Database program free medications received from drug companies. (It is called PAP: Patient Assistance Program.) The computer program automatically generates a 2013 Excel xls file of what she just scanned in. The number and names of the generated columns are always the same. All that varies is the number of rows.
My task is to update the hand-counted inventory with data from the scanned list.
I import the xls file of medications just scanned in, put the data where I want it, and close the file.
Eventually, I get to here:
'Assign Some Variables for What's to Come. Load Each Variable With Data From Successive ‘Rows of the Scanned Data List
For ScannedRow = 2 To ScanLastRow
DrgName = (Cells(Row, 12).Value)
Dose = (Cells(Row, 13).Value)
Strength = (Cells(Row, 14).Value)
Next
This is my problem area. (Please remember I’m an IT guy) But even to me, this looks kludgey. And if, by chance, she scans a medication not in the inventory list what happens? Can ELSE handle the no-match situation?
(The Drug Name, Dosage, and Strength of each medication just scanned in must find a match in an inventory row for the Qty amount of the row to be updated.)
For InventoryRow = 2 To InvLastRow
If DrgName = Range("L2").Value And Dose = Range("M2").Value And Strength = _Range("N2").Value Then Range("E15").Value = Range("E15").Value + Range("P2").Value
Next
October 5, 2010
Hi Bruce,
Welcome to the forum, can I please ask you to review this
https://www.myonlinetraininghu.....this-first
I'm not really sure what you are asking. As Mynda already told you in email, without your workbook it is difficult to imagine the data and how the code is working on it.
Syntactically your IF statement is correct.
If DrgName = Range("L2").Value And Dose = Range("M2").Value And Strength = Range("N2").Value Then Range("E15").Value = Range("E15").Value + Range("P2").Value
So could you please clearly state the issue, what the expected result is and supply your workbook.
Thanks
Phil
1 Guest(s)