Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sorting Data

I have one column with Dates and several columns with Instrument
readings, eg. Inst1, Inst2, Inst3, etc.The instruments are not read
everyday so some of the dates have blank data or zero value in the
Instruments columns. How can I write a macro to filter out the dates
with a non-zero or non-blank Instrument reading and populate in a
different sheet for each Instrument?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sorting Data

The code below is close to being right. I don't know where the instrument
names are located from your posting. I think this line in the code will need
to be changed

SHName = Cells(RowCount, _
ColumnCount).Value

right now the code is using the reading value as the sheet names. The
results will look strange.


Sub copyinstruments()

Const DateColumn = "A"
Const InstrumentStartCol = "B"
Const InstrumentEndCol = "F"

StartCol = Cells(1, InstrumentStartCol).Column
EndCol = Cells(1, InstrumentEndCol).Column

LastRow = Cells(Rows.Count, DateColumn). _
End(xlUp).Row

Set FirstSheet = ActiveSheet

For RowCount = 1 To LastRow
For ColumnCount = StartCol To EndCol
If Not IsEmpty(Cells(RowCount, _
ColumnCount)) Then

SHName = Cells(RowCount, _
ColumnCount).Value
'check if worksheet exists
Found = False
For Each ws In Worksheets
If ws.Name = SHName Then
Found = True
Exit For
End If
Next ws

If Found = False Then
Worksheets.Add after:= _
Worksheets(Worksheets.Count)
ActiveSheet.Name = SHName
FirstSheet.Activate
End If

With Worksheets(SHName)
If Found = True Then
LastRow = .Cells(Rows.Count, _
"A").End(xlUp).Row
NewRow = LastRow + 1
Else
NewRow = 1
End If

.Cells(NewRow, "A") = _
Cells(RowCount, DateColumn).Value
.Cells(NewRow, "B") = _
Cells(RowCount, ColumnCount).Value
End With
End If
Next ColumnCount
Next RowCount

End Sub

" wrote:

I have one column with Dates and several columns with Instrument
readings, eg. Inst1, Inst2, Inst3, etc.The instruments are not read
everyday so some of the dates have blank data or zero value in the
Instruments columns. How can I write a macro to filter out the dates
with a non-zero or non-blank Instrument reading and populate in a
different sheet for each Instrument?


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
data sorting CAKE LADY[_2_] Excel Worksheet Functions 1 April 8th 09 05:16 PM
Sorting of data ub Excel Worksheet Functions 2 April 1st 08 03:34 PM
sorting data [email protected] Excel Programming 0 March 6th 07 03:02 PM
Sorting data to match existing data Jack C Excel Discussion (Misc queries) 4 May 24th 06 09:48 AM
colors of bar charted data don't follow data after sorting Frankgjr Charts and Charting in Excel 2 January 17th 06 12:33 PM


All times are GMT +1. The time now is 08:48 PM.

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

About Us

"It's about Microsoft Excel"