PDA

View Full Version : Sleeper: Delimited file: Assigning names to sheets,charts



clvestin
09-08-2005, 06:11 AM
To be brief:
I sort a delimited file via a set category stamp. I then place each category's data on a seperate sheet, and chart the last 75 to 100 values of a number of select columns. Because these columns have no names, I must provide them (as well as sheet and column names too).
My method:


Sub rni4(ByVal m As Integer) ' "m" is the index (0 to 4) of a list box selection
Call labels(m) 'A sub holding nothing but arrays of columns and names
Set new2sheet = Sheets.Add(Type:=xlWorksheet)
new2sheet.Name = shtname(t) 'This is where I name the sheet
Sheet1.Rows.Range("a" & crow, "a" & drow - 1).EntireRow.Copy Destination:=Worksheets(shtname(t)).Range("a1:a1")
'This is where I produce the names for charts

Public Sub labels(ByVal m As Integer)
coldata0 = Array("b", "c") 'Boiloff columns
coldata1 = Array("c", "d", "f", "g") '301A columns
coldata2 = Array("c", "d", "f", "g") '301B columns
coldata3 = Array("b", "g", "e", "f") 'ColdBox columns
coldata4 = Array("b", "c", "x", "z") 'Temps columns
namdata0 = Array("Flow", "SucTemp") 'BO
namdata1 = Array("Suction", "Discharge", "TIT", "TOT") '301A
namdata2 = Array("Suction", "Discharge", "TIT", "TOT") '301B
namdata3 = Array("CB1_Temp", "CB2_Temp", "MidPt_Temp", "FlowTot") 'CB
namdata4 = Array("Gas_Temp", "Pressure", "CB_Flow", "ReactHtr_Temp") 'Tmps
If m = 0 Then coldata = coldata0
If m = 0 Then namdata = namdata0
If m = 1 Then coldata = coldata1
If m = 1 Then namdata = namdata1
If m = 2 Then coldata = coldata2
If m = 2 Then namdata = namdata2
If m = 3 Then coldata = coldata3
If m = 3 Then namdata = namdata3
If m = 4 Then coldata = coldata4
If m = 4 Then namdata = namdata4


I'm simply looking for a better way of addressing an unlabeled delimited file.
This method is crude, I know, but it was produced in a flurry of inspiration (perhaps misguided) and by golly, it works. Any thoughts are appreciated.

mvidas
09-08-2005, 08:08 AM
Hi clvestin,

I must admit I'm confused as to what you're asking. But, I did clean up the code you had above, hopefully it will help. If you wanted to post your full code it might shine some light on what you need and a better way to do it.


Sub rni4(ByVal m As Long) ' "m" is the index (0 to 4) of a list box selection
labels m 'A sub holding nothing but arrays of columns and names
Set new2sheet = Worksheets.Add
new2sheet.Name = shtname(t) 'This is where I name the sheet
Sheet1.Rows(crow & ":" & drow - 1).Copy new2sheet.Range("a1")
'This is where I produce the names for charts
Public Sub labels(ByVal m As Long)
Select Case m
Case 0 'Boiloff
ColData = Array("b", "c")
namdata = Array("Flow", "SucTemp")
Case 1, 2 '301A and 301B
ColData = Array("c", "d", "f", "g")
namdata = Array("Suction", "Discharge", "TIT", "TOT")
Case 3 'ColdBox
ColData = Array("b", "g", "e", "f")
namdata = Array("CB1_Temp", "CB2_Temp", "MidPt_Temp", "FlowTot")
Case 4 'Temps
ColData = Array("b", "c", "x", "z")
namdata = Array("Gas_Temp", "Pressure", "CB_Flow", "ReactHtr_Temp")
End Select

Matt

clvestin
09-09-2005, 05:40 AM
Thx for the cleanup=it was needed. Any thoughts though-How can one better approach a completely unlabled file. I had thought:
1) Sort, divide by sheet, and assign RangeName to columns , and if so Is the Array function the best way to assign these.
or:
2) Sort, don't divide by sheet, assign RangeName by address, etc
These are questions i know you can't address fully w/o being familiar with the data, but I can't help but feel there's a better way

mvidas
09-09-2005, 05:54 AM
I think I still need a little more information. Let me try and clarify what it seems like to me.

You have a delimited file which contains no columns headers, and you're wondering what the best way to put headers in is?

For example, lets just say your file looks like:
1,2,3,4,a
5,6,7,8,b
9,10,11,12,a
13,14,15,16,b

Do you want to be able to determine what is in each column and insert the headers above the first row of data?
Do you want to have 2 sheets created, one with the 'a' value in column E and one with the 'b' value in column E?

I apologize for the questions, but I'm just not completely understanding what you're asking. You don't have to give specific data, but just a little more description of what you're doing.

Thanks!
Matt