View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Macro to populate a second column

Mike,
My product categories would be in a separate sheet. There are only 10
categories.
--
Bob


"Mike H" wrote:

Bob,

Reading the 4 leftmost characters from column A used range is simple enough
with the code below for example but you don't tell us how to populate column
B. Where are the data to do this? You may not even need a macro.

Sub sonic()
Dim MyRange As Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
partno = Left(c.Value, 4)
MsgBox partno
Next
End Sub

Mike

"Bob" wrote:

I have a part list which I update monthly. In most cases the part numbers
are 10+ characters long however after the first 3 or 4 characters I can
determine what kind of part it is. What I would like to do is create a macro
that based on the first 3 to 4 characters would populate the product category
field in the second column. For example part number DF24-10W52-08LPHHN in
column "A" would equal product Category in Column "B". I would just use DF24
in the macro. Also my part list is about 40,000 lines.

Thanks.

--
Bob