+ Reply to Thread
Results 1 to 8 of 8

Expanding rows based on amount of data

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    51

    Expanding rows based on amount of data

    So I have a spread sheet that queries a database and returns data based on a date. The number of rows returned can vary from month to month. To have the data look the way people want it to I have formulas that take the data from one column and translate it into a readable form.

    My problem is I can seem to figure out how to input my formula in such a way that excel will automatically expand the number of rows based on the amount of data returned.
    Last edited by bremen22; 07-13-2013 at 06:02 PM.

  2. #2
    Forum Contributor
    Join Date
    07-07-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    256

    Re: Expanding rows based on amount of data

    hai brem can you attach a sample excell list so that response will be quick

  3. #3
    Registered User
    Join Date
    06-22-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Expanding rows based on amount of data

    bremem22,

    From what you describe the might help.

    1) Create a dynamic range (formulas, name manager) using the formula
    =OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),1).
    This will expand to the number of rows in your dataset

    2) Loop through the range using VBA and insert the formulas you need.

    Please Login or Register  to view this content.
    I have attached a spreadsheet with the above.

    Hope that helps. If not lets try again.

    Regards

    David
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    07-08-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Expanding rows based on amount of data

    I have added that formula into my sheet and when I have more data to work with I will know if it works.

    Thank you.

  5. #5
    Registered User
    Join Date
    07-08-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Expanding rows based on amount of data

    Ok...

    So I tried that with a different data set, but it didn't work.

    I am not sure about adding the formulas to the VBA script.

    Here are two examples of actual formulas in my sheet. Can you show me what the VBA would look like with these two forulas?

    For Columb B : =IF(K2="", "STK", LEFT(K2,4))
    For Column C: =IF(P2=0, "No", "Yes")

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Expanding rows based on amount of data

    THose 2 formulas by themselves dont tell us very much

    As suggested, upload a sample work book, (all sensitive data removed), showing what data you are working with, a few examples of what your expected outcome is, and how you arrived at that
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Registered User
    Join Date
    07-08-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Expanding rows based on amount of data

    Ok..... Since all of the data in my sheet is sensitive I have created a sheet as an example. All of the data in this sheet is fictitious, but it looks similar to what i actually have. The data highlighted in red will be hidden.

    Now, what is not included in this sheet is the ODBC connection and query to my Oracle database. I am not making a fake one of those. Now the query will only return rows of data that fall within the current month. The number of purchases each month will change and thus so will the amount of rows in the data set.

    Now the formulas that are in this sheet are very similar to the actual formulas I am using with the data in the formula being different.

    Hope this helps.


    Sample Data.xlsx

  8. #8
    Forum Contributor
    Join Date
    07-07-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    256

    Re: Expanding rows based on amount of data

    Hai i moved some of your data at the bottom of the sheet 1 to sheet2
    Now you add new data right from 26 th row and see if this is what you want
    and plz give feed back

    Narayanan
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. expanding data to multible rows
    By aquasport in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2013, 04:06 PM
  2. [SOLVED] Macro based on User input to Insert X amount of rows - Need advanced help
    By BuzzOffSweetheart in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2012, 07:06 PM
  3. Copy/Delete rows based on amount of cells selected
    By mcj0422 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-26-2009, 09:30 AM
  4. Highlighting rows with X amount of data!
    By EndZz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2007, 10:53 PM
  5. How can I calculate amount of time left based on amount spent?
    By KLD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-23-2006, 11:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1