Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Fairly complicated excel problem

  • 16-01-2007 1:01pm
    #1
    Registered Users, Registered Users 2 Posts: 1,227 ✭✭✭


    I am completing a college thesis. Over the past five years a machine has been spitting out data in to excel files, I only need a fraction of the information in the excel document it has created though.

    To be be exact I need one out of every six rows. Is there a function within excel to automatically delete the unrequired rows?

    Each day the machine operated it created a folder and put that days data into it. Is it possible to merge all of these files together with the click of a few buttons?

    I would really appreciate any help that you guys can give

    Steve


Comments

  • Registered Users, Registered Users 2 Posts: 8,067 ✭✭✭youcancallmeal


    A VBA macro could probably be written to do this but it would be fairly complex with so many files involved :eek:


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    I dont feel the macro need be that complicated.

    The macro below I wrote for a colleague several months ago will handle any number of excel files. The thing it will not do is copy every 6 lines. What it will do is copy the sixth line from every excel file & paste into another excel file called C:\results.xls.

    Im sure you could modify it to better suit your needs. If you do please post the code I'd be interested to seen how you do it (possibly with an additional loop).

    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 11/09/2006 by Alan
    '

    '
    Dim myFile
    Dim myRef
    'myRef = Range("l3").Value
    myFile = Dir("c:\temp\*.xls")
    Application.CutCopyMode = False
    Application.DisplayAlerts = False
    Do While Len(myFile) > 0
    Application.CutCopyMode = False
    Workbooks.Open Filename:="c:\temp\" & myFile
    Range("A1:" & myRef).Select
    Selection.Copy
    ActiveWorkbook.Close
    Workbooks.Open Filename:="C:\results.xls"
    ActiveSheet.Paste
    ActiveCell.Offset(1, 0).Range("A6:iv6").Select
    ActiveWorkbook.Save
    ActiveWorkbook.Close ' or process here
    myFile = Dir
    Loop

    End Sub


    Further Comments
    Macro1 will:
    Loop through each XLS file in C:\Temp
    Open the first XLS file
    Copy the contents of cells A6:IV6 (all cells in row 6)
    Close the first XLS file
    Open C:\Results.XLS
    Paste the clipboard contents into the first unpopulated cell in column A
    Save Results.XLS
    Close C:\Results.XLS
    Continue to the next iteration of the Loop I.E. the next XLS file in C:\Temp.


    Alan:cool:


  • Registered Users, Registered Users 2 Posts: 68 ✭✭alancool


    Sorry the macro in the last post was wrong. Here's the correction.



    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 11/09/2006 by Alan
    '

    '
    Dim myFile
    Dim myRef
    myRef = Range("l3").Value
    myFile = Dir("c:\temp\*.xls")
    Application.CutCopyMode = False
    Application.DisplayAlerts = False
    Do While Len(myFile) > 0
    Application.CutCopyMode = False
    Workbooks.Open Filename:="c:\temp\" & myFile
    Range("A6:IV6").Select
    Selection.Copy
    ActiveWorkbook.Close
    Workbooks.Open Filename:="C:\results.xls"
    ActiveSheet.Paste
    'ActiveCell.Offset(1, 0).Range("A1:J1").Select
    ActiveCell.Offset(1, 0).Range("A1:" & myRef).Select
    ActiveWorkbook.Save
    ActiveWorkbook.Close ' or process here
    myFile = Dir
    Loop

    End Sub


  • Registered Users, Registered Users 2 Posts: 1,227 ✭✭✭stereo_steve


    Thanks alot guys.

    I found a program http://www.sobolsoft.com/excelcsv/ which joined all the excel files I had into one large excel file. I'm now going to tinker around with themacro alancool posted.


    I'll post up how it goes...


  • Registered Users, Registered Users 2 Posts: 1,227 ✭✭✭stereo_steve


    AS it turned out I decided to use all the information and my results should just be more accurate. So after all that no macro!

    I do have a new problem though. Something I'm sure someone could answer in 2mins!

    I want to calculate a series of averages.

    My first cell looks like this:

    =AVERAGE(D3:D996)

    I then want both numbers to be incremented by 992 and then the third cell to be incremented by 992 again etc

    Any help would be really appreciated!


  • Advertisement
Advertisement