View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Excel - Stock Macro Help

Let me know if this helps.

Sub changeproductcodes()
For i = Cells(Rows.Count, "d").End(xlUp).Row To 14 Step -1
Rows(i - 1).Insert
c = Cells(i, "d")
p1 = InStr(c, " ")
p2 = InStr(p1, c, "/")
p3 = InStr(p2, c, " ")
s1 = Left(c, p1 - 1) & "-1" & Mid(c, p1, p2 - p1) & Right(c, Len(c) - p3 +
1)
s2 = Left(c, p1 - 1) & "-2 " & Mid(c, p2 + 1, p3 - p2) & Right(c, Len(c) -
p3 + 1)
Cells(i, "d").Value = s1
Cells(i + 1, "d").Value = s2
Next i
End Sub

--
Don Guillett
SalesAid Software

"Materialised" wrote in message
...
Hi All,

I have a very large sheet, which covers a suppliers range of products.
The format is as follows:
ALDL/A/R Glass/Nkl 75 25.51 51.02 £51.02

Where the first column is the product code, the second relates to the
colours of the product available.
What I need to do, is loop through the sheet, and create individual rows
for each available product.
So instead of the above, I would have something like:
ALDL/A/R-1 Glass 75 25.51 51.02 £51.02
ALDL/A/R-2 Nkl 75 25.51 51.02 £51.02
The product code has now changes, to reflect an individual product.
I am very new to excel programming and have only covered the simplest of
things, but the way I see it working is the user would specify a column
which in this would be B to indicated which column the various colour
codes are in. Then they would have to specify a seperator character
which in this case would be "/" (these are not always the same) then the
macro would loop through the sheet, making the alerations.
Could anyone give me a few pointers on how I could do this please, as I
said before, I am not to good with writing macros.

Thanks

(Sorry for the repost, I didnt want any title confusion with a previous
post)