Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Intricate Cell Formatting Question

Try...

Sub ParsePartNums()
Dim vDataIn, vNum, vConfigs, vTemp$(), v
Dim n&, i&, k&, j&, x&, lRows&, lCols&

With ActiveSheet
lRows = .Cells(.Rows.Count, 1).End(xlUp).Row
lCols = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
vDataIn = ActiveSheet.Range(Cells(1, 1), Cells(lRows, lCols))
ReDim vTemp(0)

'Parse the data
For n = LBound(vDataIn) To UBound(vDataIn)
If InStr(1, vDataIn(n, 1), ",") 0 Then
vNum = Split(vDataIn(n, 1), "-"): vConfigs = Split(vNum(2), ",")
'Get current num elements and reset counter
j = UBound(vTemp) + 1: x = 0
ReDim Preserve vTemp(UBound(vTemp) + UBound(vConfigs) + 1)
For k = j To UBound(vTemp)
vTemp(k) = Join(Array(vNum(0), vNum(1), vConfigs(x)), "-")
For i = 2 To UBound(vDataIn, 2)
vTemp(k) = Join(Array(vTemp(k), vDataIn(n, i)))
Next 'i
x = x + 1
Next 'k
Else
ReDim Preserve vTemp(UBound(vTemp) + 1)
vTemp(UBound(vTemp)) = vDataIn(n, 1)
For i = 2 To UBound(vDataIn, 2)
vTemp(UBound(vTemp)) = _
Join(Array(vTemp(UBound(vTemp)), vDataIn(n, i)))
Next 'i
End If
Next 'n

'Bypass limitations of WorksheetFunction.Transpose
ReDim vDataOut(1 To UBound(vTemp), 1 To lCols)
For n = 1 To UBound(vTemp)
v = Split(vTemp(n))
For j = 0 To UBound(v)
vDataOut(n, j + 1) = v(j)
Next 'j
Next 'n

'Dump the data into the worksheet
Range("A1").Resize(UBound(vDataOut), lCols) = vDataOut
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting question (if cell = 0, wrap cell in quotes) Mo2 New Users to Excel 6 May 11th 07 11:06 PM
Another cell formatting dependent on cell contents question / message box popup? StargateFan[_3_] Excel Programming 2 January 14th 06 02:47 PM
Another Cell formatting Question. 43fan Excel Programming 6 March 4th 05 06:51 PM
INTRICATE PROBLEM- How to find multiple text,excluding "H", in a multiple range of cells, then replacing 0 with another number in another cell Tourcat Excel Worksheet Functions 1 February 8th 05 06:26 PM
Cell formatting question Wexler[_2_] Excel Programming 1 December 6th 04 10:31 PM


All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"