PC Review


Reply
 
 
Cesar
Guest
Posts: n/a
 
      22nd Feb 2010
Hello All,
I have a range of cells (A1:A3000) with codes for items in a warehouse,
there are about 3000 items, there are also 10 cathegories. I want to, in
range B1:B3000 write the name of the cathegory that the item belong; the
items' codes are totaly different one from the other, example:

A B
ACTU VALVES
EFTG CONDUIT
COND CONDUIT
IFTG TUBING
XMTR TRANSMITTER

I have done this using a lot nested IF on cells B:B3000.
Is there a way to write a code to do this faster?

Thanks in Advance,


--
Cesar
 
Reply With Quote
 
 
 
 
marcus
Guest
Posts: n/a
 
      22nd Feb 2010
Hi Cesar

I would suggest you write a vlookup to check the unique code against
each category. In another table create a list of all the unique
items. Then next to the item place its category name.

Then in cell B2 type this formula

=Vlookup(A1,MyTable,2,0)

Where Mytable is reference to the list of items and categories and 2
is the columns offset from the found item.

My concern with this suggestion is if you know how to do this with a
nested if statement then a vlookup should have occurred to you.

Take care

Marcus

 
Reply With Quote
 
keiji kounoike
Guest
Posts: n/a
 
      22nd Feb 2010
I would make a data sheet and make a table of items and category there.
A table looks like below, for example.

A B C D E
1 Category VALVES CONDUIT TUBING TRANSMITTER
2 item ACTU EFTG IFTG XMTR
COND

Try this one. I named data sheet as "Category" in the code below.

Sub Categorytest()
Dim TarRng As Range
Dim startrow As Long, strowdata As Long, codecolnum As Long
Dim codecol As String

With Worksheets("Category")

strowdata = 1 'start row's number in Category sheet
codecolnum = 2 'start column's number in Category sheet
startrow = 2 'start row's number in data sheet
codecol = "A" 'column where code reside

Set TarRng = .Cells(strowdata, "A").CurrentRegion
Set TarRng = TarRng.Offset(, codecolnum - 1) _
.Resize(, TarRng.Columns.Count - 1)

For i = startrow To Cells(startrow, codecol).End(xlDown).Row
Set tmp = TarRng.Find(Cells(i, codecol).Value, lookat:=xlWhole)

If Not tmp Is Nothing Then
Cells(i, codecol).Offset(0, 1) = .Cells(strowdata, tmp.Column)
Else
Cells(i, codecol).Offset(0, 1) = "Can't find Category"
End If
Next

End With

End Sub

Keiji

Cesar wrote:
> Hello All,
> I have a range of cells (A1:A3000) with codes for items in a warehouse,
> there are about 3000 items, there are also 10 cathegories. I want to, in
> range B1:B3000 write the name of the cathegory that the item belong; the
> items' codes are totaly different one from the other, example:
>
> A B
> ACTU VALVES
> EFTG CONDUIT
> COND CONDUIT
> IFTG TUBING
> XMTR TRANSMITTER
>
> I have done this using a lot nested IF on cells B:B3000.
> Is there a way to write a code to do this faster?
>
> Thanks in Advance,
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linq to XML--Are there code examples that make Linq as easy as SQL? Or how can I convert ths simple pseudo code into real code? Reece Microsoft C# .NET 4 10th Dec 2008 03:13 AM
ATI Radeon Drivers - Code 43, Code 37 & Code 10 =?Utf-8?B?SmFrZQ==?= Windows Vista Hardware 14 29th Aug 2006 05:50 AM
ATI Display Drivers - Code 43, Code 37, Code 10 Jake Windows Vista Hardware 2 8th Jul 2006 04:00 PM
what is the difference between code inside a <script> tag and code in the code-behind file? keithb Microsoft ASP .NET 1 29th Mar 2006 02:00 AM
[New] Zipoid - ZIP Code, City Name and Area Code Lookup - Zip Code to Zip Code Distance Calculation Mel Freeware 0 22nd Jul 2005 04:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:04 PM.