LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel, find and copying to worksheets

Hi
 
I was wondering if anyone can help me. I am streaming a load of data into excel. I then want to split up the data, by copying each relevant row to a new sheet.
 
I've got to the position wher the data is written to a 'master' worksheet and then create 7 empty worksheets. What I now need to do is search column B of the 'master' sheet , if the value 1 is found then copy the row to sheet1, 2 sheet 2 etc upto 7 values. This is not a constant number but will be between 1 and 7.
 
Any ideas on how I can do this?
 
Cheers
 
Dave
0 Kudos
Message 1 of 2
(2,308 Views)

Hi David

Record what you want to do as a macro in excel. Then use the excel VB Editor to view the code. This will let you see objects, methods and properties used. Then its a matter of converting the VBA code into labview property and invoke nodes.

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 21/06/2006 by dcrawford
'

'
    Cells.Find(What:="1", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
    Rows("1:1").Select
    Selection.Copy
    Sheets("Sheet1").Select
    Rows("1:1").Select
    ActiveSheet.Paste
    Sheets("Master").Select
    Range("A1").Select
    Cells.Find(What:="2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
    Rows("2:2").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet2").Select
    Rows("1:1").Select
    ActiveSheet.Paste
    Sheets("Master").Select
    Range("A1").Select
    Cells.Find(What:="3", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
    Rows("3:3").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet3").Select
    Rows("1:1").Select
    ActiveSheet.Paste
End Sub

I find this is a great starting place. Have you tried this before?

David

Message 2 of 2
(2,301 Views)