Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default arrays and labeling

Hi all,

I have 50 hours of data, second by second in excel. I am trying to label
each point as 1 of 4 modes based on certain criteria. My 'Oxygen' is a
column that says if my oxygen is on or not. My UEGO is another column that
is either at 1 or 0.9. These are the criteria for the modes.

Mode 1 (~10sec):
Oxygen = 0
UEGO ~ 1

Mode 2 (~10 sec):
Oxygen = 0
UEGO ~ 0.9

Mode 3 (~5 sec):
Oxygen = 1
UEGO ~ 0.9

Mode 4 (~10 sec):
Oxygen = 1
UEGO ~1

I'd like to use arrays to label the data to make this process fast. My
array knowlege is a little weak.

Any help would be greatly appreciated!
Thanks!
Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default arrays and labeling

Ok,

I tried my luck and I've got it up to the point where I need to paste the
data into excel. What I'm tracking with the Watch on arrLabel is not
matching what I'm getting when pasted into excel.

ReDim arrLabel(1 To LastRow) As Variant
ReDim arrFUEGO(1 To LastRow) As Variant
ReDim arrOxygen(1 To LastRow) As Variant

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

For j = 1 To LastRow
If Round(arrFUEGO(j, 1), 1) = 1 Then
If arrOxygen(j, 1) 0 Then
arrLabel(j) = "Mode 4"
Else
arrLabel(j) = "Mode 1"
End If
Else
If arrOxygen(j, 1) 0 Then
arrLabel(j) = "Mode 3"
Else
arrLabel(j) = "Mode 2"
End If
End If
Next

ActiveSheet.Range("X8:X" & LastRow).Value = arrLabel

What's wrong with that last line?
Thanks!
Matt


"Matt S" wrote:

Hi all,

I have 50 hours of data, second by second in excel. I am trying to label
each point as 1 of 4 modes based on certain criteria. My 'Oxygen' is a
column that says if my oxygen is on or not. My UEGO is another column that
is either at 1 or 0.9. These are the criteria for the modes.

Mode 1 (~10sec):
Oxygen = 0
UEGO ~ 1

Mode 2 (~10 sec):
Oxygen = 0
UEGO ~ 0.9

Mode 3 (~5 sec):
Oxygen = 1
UEGO ~ 0.9

Mode 4 (~10 sec):
Oxygen = 1
UEGO ~1

I'd like to use arrays to label the data to make this process fast. My
array knowlege is a little weak.

Any help would be greatly appreciated!
Thanks!
Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default arrays and labeling

I cleaned up the code a bit, but it still will not paste the array correctly
in excel! I can see using the watch in VB that the array is being created
correctly. It is cycling through all the modes, but when pasting all excel
says down the entire column is "Mode 1." This is infuriating. My data
starts at row 8, so that is why I have the array start there. It does the
same thing if I start the array at 1.

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

'Declare Arrays
ReDim arrLabel(8 To LastRow) As String
ReDim arrFUEGO(8 To LastRow) As Double
ReDim arrOxygen(8 To LastRow) As Double

For j = 8 To LastRow
arrFUEGO(j) = Range("P" & j).Value
arrOxygen(j) = Range("E" & j).Value
Next j

For j = 8 To LastRow
If Round(arrFUEGO(j), 1) <= 0.95 Then
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 3"
Else
arrLabel(j) = "Mode 2"
End If
Else
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 4"
Else
arrLabel(j) = "Mode 1"
End If
End If
Next


ActiveSheet.Range("Y8:Y" & LastRow).Value = arrLabel

If I look at the array in the watch it looks like this:
arrLabel(8) = "Mode 1"
...
...
arrLabel(55) = "Mode 2"
...
arrLabel(60) = "Mode 3"
...
arrLabel(70) = "Mode 4"



"Matt S" wrote:

Hi all,

I have 50 hours of data, second by second in excel. I am trying to label
each point as 1 of 4 modes based on certain criteria. My 'Oxygen' is a
column that says if my oxygen is on or not. My UEGO is another column that
is either at 1 or 0.9. These are the criteria for the modes.

Mode 1 (~10sec):
Oxygen = 0
UEGO ~ 1

Mode 2 (~10 sec):
Oxygen = 0
UEGO ~ 0.9

Mode 3 (~5 sec):
Oxygen = 1
UEGO ~ 0.9

Mode 4 (~10 sec):
Oxygen = 1
UEGO ~1

I'd like to use arrays to label the data to make this process fast. My
array knowlege is a little weak.

Any help would be greatly appreciated!
Thanks!
Matt

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default arrays and labeling

ActiveSheet.Range("Y8:Y" & LastRow).Value = arrLabel
should be:
ActiveSheet.Range("Y8:Y" & LastRow).Value = application.transpose(arrLabel)

I like to qualify my ranges, too. I'd use:

Option Explicit
Sub testme()

Dim LastRow As Long
Dim j As Long
Dim arrLabel() As String
Dim arrFUEGO() As Double
Dim arrOxygen() As Double

With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

'redim Arrays
ReDim arrLabel(8 To LastRow)
ReDim arrFUEGO(8 To LastRow)
ReDim arrOxygen(8 To LastRow)

For j = 8 To LastRow
arrFUEGO(j) = .Range("P" & j).Value
arrOxygen(j) = .Range("E" & j).Value
Next j

For j = LBound(arrFUEGO) To UBound(arrFUEGO)
If Round(arrFUEGO(j), 1) <= 0.95 Then
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 3"
Else
arrLabel(j) = "Mode 2"
End If
Else
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 4"
Else
arrLabel(j) = "Mode 1"
End If
End If
Next j

'.Range("Y8:Y" & LastRow).Value = Application.Transpose(arrLabel)

'or
'I like this syntax so I don't have to care or know about the
'upper bound
.Range("Y8").Resize(UBound(arrFUEGO) - LBound(arrFUEGO) + 1).Value _
= Application.Transpose(arrLabel)

End With

End Sub


Matt S wrote:

I cleaned up the code a bit, but it still will not paste the array correctly
in excel! I can see using the watch in VB that the array is being created
correctly. It is cycling through all the modes, but when pasting all excel
says down the entire column is "Mode 1." This is infuriating. My data
starts at row 8, so that is why I have the array start there. It does the
same thing if I start the array at 1.

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

'Declare Arrays
ReDim arrLabel(8 To LastRow) As String
ReDim arrFUEGO(8 To LastRow) As Double
ReDim arrOxygen(8 To LastRow) As Double

For j = 8 To LastRow
arrFUEGO(j) = Range("P" & j).Value
arrOxygen(j) = Range("E" & j).Value
Next j

For j = 8 To LastRow
If Round(arrFUEGO(j), 1) <= 0.95 Then
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 3"
Else
arrLabel(j) = "Mode 2"
End If
Else
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 4"
Else
arrLabel(j) = "Mode 1"
End If
End If
Next


ActiveSheet.Range("Y8:Y" & LastRow).Value = arrLabel

If I look at the array in the watch it looks like this:
arrLabel(8) = "Mode 1"
..
..
arrLabel(55) = "Mode 2"
..
arrLabel(60) = "Mode 3"
..
arrLabel(70) = "Mode 4"

"Matt S" wrote:

Hi all,

I have 50 hours of data, second by second in excel. I am trying to label
each point as 1 of 4 modes based on certain criteria. My 'Oxygen' is a
column that says if my oxygen is on or not. My UEGO is another column that
is either at 1 or 0.9. These are the criteria for the modes.

Mode 1 (~10sec):
Oxygen = 0
UEGO ~ 1

Mode 2 (~10 sec):
Oxygen = 0
UEGO ~ 0.9

Mode 3 (~5 sec):
Oxygen = 1
UEGO ~ 0.9

Mode 4 (~10 sec):
Oxygen = 1
UEGO ~1

I'd like to use arrays to label the data to make this process fast. My
array knowlege is a little weak.

Any help would be greatly appreciated!
Thanks!
Matt


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default arrays and labeling

Dave,

Why do you first Dim and then ReDim the arrays?

Thanks!
Matt


"Dave Peterson" wrote:

ActiveSheet.Range("Y8:Y" & LastRow).Value = arrLabel
should be:
ActiveSheet.Range("Y8:Y" & LastRow).Value = application.transpose(arrLabel)

I like to qualify my ranges, too. I'd use:

Option Explicit
Sub testme()

Dim LastRow As Long
Dim j As Long
Dim arrLabel() As String
Dim arrFUEGO() As Double
Dim arrOxygen() As Double

With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

'redim Arrays
ReDim arrLabel(8 To LastRow)
ReDim arrFUEGO(8 To LastRow)
ReDim arrOxygen(8 To LastRow)

For j = 8 To LastRow
arrFUEGO(j) = .Range("P" & j).Value
arrOxygen(j) = .Range("E" & j).Value
Next j

For j = LBound(arrFUEGO) To UBound(arrFUEGO)
If Round(arrFUEGO(j), 1) <= 0.95 Then
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 3"
Else
arrLabel(j) = "Mode 2"
End If
Else
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 4"
Else
arrLabel(j) = "Mode 1"
End If
End If
Next j

'.Range("Y8:Y" & LastRow).Value = Application.Transpose(arrLabel)

'or
'I like this syntax so I don't have to care or know about the
'upper bound
.Range("Y8").Resize(UBound(arrFUEGO) - LBound(arrFUEGO) + 1).Value _
= Application.Transpose(arrLabel)

End With

End Sub


Matt S wrote:

I cleaned up the code a bit, but it still will not paste the array correctly
in excel! I can see using the watch in VB that the array is being created
correctly. It is cycling through all the modes, but when pasting all excel
says down the entire column is "Mode 1." This is infuriating. My data
starts at row 8, so that is why I have the array start there. It does the
same thing if I start the array at 1.

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

'Declare Arrays
ReDim arrLabel(8 To LastRow) As String
ReDim arrFUEGO(8 To LastRow) As Double
ReDim arrOxygen(8 To LastRow) As Double

For j = 8 To LastRow
arrFUEGO(j) = Range("P" & j).Value
arrOxygen(j) = Range("E" & j).Value
Next j

For j = 8 To LastRow
If Round(arrFUEGO(j), 1) <= 0.95 Then
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 3"
Else
arrLabel(j) = "Mode 2"
End If
Else
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 4"
Else
arrLabel(j) = "Mode 1"
End If
End If
Next


ActiveSheet.Range("Y8:Y" & LastRow).Value = arrLabel

If I look at the array in the watch it looks like this:
arrLabel(8) = "Mode 1"
..
..
arrLabel(55) = "Mode 2"
..
arrLabel(60) = "Mode 3"
..
arrLabel(70) = "Mode 4"

"Matt S" wrote:

Hi all,

I have 50 hours of data, second by second in excel. I am trying to label
each point as 1 of 4 modes based on certain criteria. My 'Oxygen' is a
column that says if my oxygen is on or not. My UEGO is another column that
is either at 1 or 0.9. These are the criteria for the modes.

Mode 1 (~10sec):
Oxygen = 0
UEGO ~ 1

Mode 2 (~10 sec):
Oxygen = 0
UEGO ~ 0.9

Mode 3 (~5 sec):
Oxygen = 1
UEGO ~ 0.9

Mode 4 (~10 sec):
Oxygen = 1
UEGO ~1

I'd like to use arrays to label the data to make this process fast. My
array knowlege is a little weak.

Any help would be greatly appreciated!
Thanks!
Matt


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default arrays and labeling

I like all my declarations at the top.

I'm not sure if it makes a difference technically, but it makes more sense to me
that way.

Matt S wrote:

Dave,

Why do you first Dim and then ReDim the arrays?

Thanks!
Matt

"Dave Peterson" wrote:

ActiveSheet.Range("Y8:Y" & LastRow).Value = arrLabel
should be:
ActiveSheet.Range("Y8:Y" & LastRow).Value = application.transpose(arrLabel)

I like to qualify my ranges, too. I'd use:

Option Explicit
Sub testme()

Dim LastRow As Long
Dim j As Long
Dim arrLabel() As String
Dim arrFUEGO() As Double
Dim arrOxygen() As Double

With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

'redim Arrays
ReDim arrLabel(8 To LastRow)
ReDim arrFUEGO(8 To LastRow)
ReDim arrOxygen(8 To LastRow)

For j = 8 To LastRow
arrFUEGO(j) = .Range("P" & j).Value
arrOxygen(j) = .Range("E" & j).Value
Next j

For j = LBound(arrFUEGO) To UBound(arrFUEGO)
If Round(arrFUEGO(j), 1) <= 0.95 Then
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 3"
Else
arrLabel(j) = "Mode 2"
End If
Else
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 4"
Else
arrLabel(j) = "Mode 1"
End If
End If
Next j

'.Range("Y8:Y" & LastRow).Value = Application.Transpose(arrLabel)

'or
'I like this syntax so I don't have to care or know about the
'upper bound
.Range("Y8").Resize(UBound(arrFUEGO) - LBound(arrFUEGO) + 1).Value _
= Application.Transpose(arrLabel)

End With

End Sub


Matt S wrote:

I cleaned up the code a bit, but it still will not paste the array correctly
in excel! I can see using the watch in VB that the array is being created
correctly. It is cycling through all the modes, but when pasting all excel
says down the entire column is "Mode 1." This is infuriating. My data
starts at row 8, so that is why I have the array start there. It does the
same thing if I start the array at 1.

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

'Declare Arrays
ReDim arrLabel(8 To LastRow) As String
ReDim arrFUEGO(8 To LastRow) As Double
ReDim arrOxygen(8 To LastRow) As Double

For j = 8 To LastRow
arrFUEGO(j) = Range("P" & j).Value
arrOxygen(j) = Range("E" & j).Value
Next j

For j = 8 To LastRow
If Round(arrFUEGO(j), 1) <= 0.95 Then
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 3"
Else
arrLabel(j) = "Mode 2"
End If
Else
If arrOxygen(j) 0 Then
arrLabel(j) = "Mode 4"
Else
arrLabel(j) = "Mode 1"
End If
End If
Next


ActiveSheet.Range("Y8:Y" & LastRow).Value = arrLabel

If I look at the array in the watch it looks like this:
arrLabel(8) = "Mode 1"
..
..
arrLabel(55) = "Mode 2"
..
arrLabel(60) = "Mode 3"
..
arrLabel(70) = "Mode 4"

"Matt S" wrote:

Hi all,

I have 50 hours of data, second by second in excel. I am trying to label
each point as 1 of 4 modes based on certain criteria. My 'Oxygen' is a
column that says if my oxygen is on or not. My UEGO is another column that
is either at 1 or 0.9. These are the criteria for the modes.

Mode 1 (~10sec):
Oxygen = 0
UEGO ~ 1

Mode 2 (~10 sec):
Oxygen = 0
UEGO ~ 0.9

Mode 3 (~5 sec):
Oxygen = 1
UEGO ~ 0.9

Mode 4 (~10 sec):
Oxygen = 1
UEGO ~1

I'd like to use arrays to label the data to make this process fast. My
array knowlege is a little weak.

Any help would be greatly appreciated!
Thanks!
Matt


--

Dave Peterson


--

Dave Peterson
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
Trouble with arrays (transferring values between two arrays) Keith R[_2_] Excel Programming 4 November 14th 07 12:00 AM
Working with ranges in arrays... or an introduction to arrays Glen Excel Programming 5 September 10th 06 08:32 AM
Arrays - declaration, adding values to arrays and calculation Maxi[_2_] Excel Programming 1 August 17th 06 04:13 PM
Labeling plots! aiyer[_70_] Excel Programming 6 November 24th 04 05:33 PM
labeling Adam Klee Excel Programming 1 September 14th 03 02:35 PM


All times are GMT +1. The time now is 01:15 PM.

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"