1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Excel code question

Discussion in 'Business Applications' started by galbrig, Jul 17, 2009.

Thread Status:
Not open for further replies.
Advertisement
  1. galbrig

    galbrig Thread Starter

    Joined:
    Jul 17, 2009
    Messages:
    2
    I am trying to set up a Excel file which will prompt the operator enter the lowest and higest cell row number which is needed and then will perform several operations using the data within the slected region.

    example of what I want: I have 1 columns and 100 rows and I only need to take the average of each column on row 40 to row 50.

    So the program ask me to enter in the lowest row, and the hightest row and takes an average in that region.

    I now want to analys rows 60 to 70 with out changing the code.

    How would I go about writing such a file in excel
     
  2. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    Welcome to the board. :)

    Sub test()
    StartRow = Application.InputBox("Enter lowest row number.")
    EndRow = Application.InputBox("Enter highest row number.")
    AvgRows = EndRow - StartRow + 1
    MsgBox WorksheetFunction.Average(Range("A" & StartRow).Resize(AvgRows))
    End Sub
     
  3. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Hi there, welcome to the board!

    Perhaps you can explain to us what it is you are looking for as an end result in this workbook? Just for you to play around with? It sounds like something a little bigger than what you've posted here. Maybe it's my errant imagination though...

    Hiya Andy. :)
     
  4. galbrig

    galbrig Thread Starter

    Joined:
    Jul 17, 2009
    Messages:
    2
    Thanks to the welcome,
    I guess that best way to start out is I have a test which writes information to a excel file, and procedure requires that no matter how many test I run all information must be kept in the same place. in other words I have over 2000 rows or information and counting.

    I have to take an average of the last hour of testing and make sure that none of the data is more than two hundred thousands off the average and I want it to do something like prompt me which rows to calculate instead of having to go into the code every. this is primarily so someone else can run the test with out me
     
  5. WT1059

    WT1059

    Joined:
    May 13, 2009
    Messages:
    60
    Hi and welcome. the Macro that bomb#21 gave you will run exactly what your looking for. If this is something that you have to run at a given time interval, such as every 2 hours you could add:

    Application.OnTime Now + TimeValue("02:00:00"), "test"

    just befor the End Sub and it will automatically pop up and prompt you so long as the spreadsheet is open. It's a great thing to have going if you, like me, are constantly multi-tasking and are a bit ADD as well.:)

    Peace Out
    WT1059
     
  6. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Is there a date/time stamp with each entry? Or is it the last x entries in a row/column? If so, no need for the input boxes.

    @WT1059: I would not recommend using OnTime, but rather a windows scheduled event. MHO.
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/843997

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice