VBA excel Inventory Report

March 11, 2012 at 23:29:51
Specs: Windows 7
I am trying to build a program in VBA for excel to solve the following problem: I am given 10000 numbers from A1 to A10000. I need to write a macro that will count loop through them, and create a list that will tell me how many of each number is present in the list. (The 10000 have many repeating numbers). I'm having a lot of trouble with this...
The solution must use at least one declared variable, at least one decision structure and one loop (you may actually need more than one of each).

What code would be best for this??

See More: VBA excel Inventory Report

Report •

March 12, 2012 at 01:55:52
This sounds like a homework problem.

We try to help with homework problems but not actually do them for members.

You'll have to at least give it a try and post your attempt. We'll make comments on your attempt and point you in the right direction.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

March 12, 2012 at 23:47:23
I have a code here but its not working:

Public Sub CreateInventoryReport()
Dim bcode As Long
Dim ubcode As Long
'Below is the part that is not working
If Worksheets("Sheet 2").Range("A1")<>" Then
'First Value Is unique
Worksheets("Sheet2").Range("D5") = Worksheets("Sheet2").Range("A1")
Worksheets("Sheet2").Range("E5") = 1
r = MsgBox("no data", , "no data")
Exit Sub
End If
bcode = 2

Do While Worksheets("Sheet 2").Cell(bcode, 1) <> ""
ubcode = 5
IsMatch = False
Do While Worksheets("Sheet 2").Cell(ubcode, 4) <> ""
If Worksheets("Sheet 2").Cell(bcode, 1) = Worksheets("Sheets2").Cell(ubcode, 4) Then
Worksheets("Sheet 2").Cell(ubcode, 5) = Worksheets("Sheet2").Cell(ubcode, 5) + 1
IsMatch = True
Exit Do
End If
ubcode = ubcode + 1
If IsMatch = False Then
Worksheets("Sheet2").Cell(ubcode, 4) = Worksheets("Sheet2").Cell(bcode, 1)
Worksheets("Sheet 2").Cell(ubcode, 5) = 1
End If
bcode = bcode + 1
End Sub

Report •

Related Solutions

Ask Question