I'm guessing I didnt give enough information.
I have several columns of data.
depending on the test which was performed i select the column header and run an macro looking for a change in the value by a specified percentage. The first time it is run it needs to create a worksheet named summary, the next time it is run I need to pass the create sheet command and only extract the data/ref I am looking for an copy it to the sheet "Summary". I have everything working fine except the skipping the create sheet part. The code is attached below.
Sub deviation_event()
'
Sheets.Add
ActiveSheet.Name = "summary"
Range("A1").Select
ActiveCell.FormulaR1C1 = "SUMMARY"
'
Sheets("DATA").Select
'
'
' Application.ScreenUpdating = False
'
'
Dim CH_VALUE, HI_EVENT, LO_EVENT, DEV_PERCENT, DEV_VALUE
'
'EVENT VALUE FOR CHANNEL
'
DEV_PERCENT = Range("[macros.xls]SETPOINTS!C6")
'
'
'
' FIRST CHANNEL
'
ActiveCell.Select 'STARTING POINT
'
CH_VALUE = ActiveCell.Offset(50, 0) 'READ CURRENT VALUE FROM DATA, SKIP DOWN 50 LINES TO REMOVE STARING NOISE
DEV_VALUE = CH_VALUE * DEV_PERCENT 'ESTABLISH DEVIATION LIMITS
HI_EVENT = CH_VALUE + DEV_VALUE 'SET HIGH LIMIT FOR DISPLAY ONLY
LO_EVENT = CH_VALUE - DEV_VALUE 'SET LOW LIMIT FOR DISPLAY ONLY
MsgBox "HI_EVENT = " & HI_EVENT & vbCrLf & "LO_EVENT = " & LO_EVENT
'
ActiveCell.Offset(50, 0).Select ' START LOOKING FOR EVENT
Do Until Abs(ActiveCell.Value - CH_VALUE) > DEV_VALUE Or ActiveCell.Value = vbNullString 'LOOP FOR EVENT / EVENT SETPOINT ( < 30 )
ActiveCell.Offset(1, 0).Select
Loop
If ActiveCell.Value <> vbNullString Then
ActiveCell.Offset(0, -1).Copy 'COPY THE TIME STAMP
Selection.End(xlUp).Select 'RETURN TO TOP OF PAGE
ActiveCell.Offset(-1, 0).Select '
ActiveSheet.Paste 'PASTE TIME OF EVENT ABOVE THE CHANNEL LABEL
ActiveCell.Offset(1, 0).Select 'SELECT THE CHANNEL LABEL
Range(Selection, Selection.End(xlUp)).Copy 'SELECT THE CHANNEL LABEL AND EVENT TIME
'
Sheets("SUMMARY").Select 'CHANGE TO SUMMARY SHEET
Application.Range("A1").Select 'STARTING POINT FOR EVENT LOG
Do Until ActiveCell.Value = vbNullString 'LOOP TO FIND EMPTY ROW
ActiveCell.Offset(1, 0).Select
Loop
'
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Application.CutCopyMode = False
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = "Input change by more than: " & DEV_VALUE
Else
Sheets("SUMMARY").Select 'CHANGE TO SUMMARY SHEET
Application.Range("A1").Select 'STARTING POINT FOR EVENT LOG
Do Until ActiveCell.Value = vbNullString 'LOOP TO FIND EMPTY ROW
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Value = "NO DATA"
End If
Range("A1").Select
Sheets("SUMMARY").Select
Range("A1").Select
MsgBox "EVENT DATA COMPLETE"
' Application.ScreenUpdating = True
End Sub