+ Reply to Thread
Results 1 to 4 of 4

making macro dynamic

  1. #1
    Registered User
    Join Date
    05-01-2013
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    39

    making macro dynamic

    1) issue number one-

    Im using

    ctr = Range("B2", Range("B2").End(xlDown)).Count

    to determine the number of rows of data that is used in a excel sheet.

    below are the columns that are used in the sheet.

    start date, end date, greater than 90 days( this column is inserted by me)

    the greater than 90 days just calculates the difference between the start date and the end date. depending on the number of rows, i want the macro to calculate dynamically till the last row only for the - greater than 90 days column. How can i do this? Is it possible to set the range to the cell B2??

    2) the sheet that i am working on is not standardized. so the fields that i require may be located in different columns.
    for example in one sheet, the start date might be in column A, in another sheet the start date might be in column B.
    Is it possible to create a macro using the name instead of the cell? How can this be done.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: making macro dynamic

    1.
    Assuming your greater than 90 days is in column c and has a header in row 1
    Range("C2:C" & Range("C" & rows.count).end(xlup).row).formulaR1C1 = "=RC[-1]-RC[-2]"

    2.
    To use a named range:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-01-2013
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: making macro dynamic

    Capture.JPG

    I guess there is some cofusion in the requirement. Have attached a screenshot of the requirement. Please assist

  4. #4
    Registered User
    Join Date
    05-01-2013
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: making macro dynamic

    Summarizing my requirement:
    The image attached has the table and requirement as well.. Image will help in understanding

    1)The number of rows in the excel sheet is unknown. The columns need not be in the same order as presented. That is why, need a macro that can find the required column based on the cell value and not the cell address.

    2)Need to insert a new column in the data - " greater than 90 days", which will have the difference between the start date and the end date
    3)Need to find out the number of rows in the excel sheet, so that the " greater than 90 days" column can be calculated for each row in the sheet dymanically.

    Please helpCapture.JPG

+ 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. [SOLVED] Macro to sum a dynamic/variable range - I'm making this harder than it has to be, I think.
    By ajava in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-07-2012, 02:48 PM
  2. help with making a dynamic variable
    By squeekee35 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2011, 11:01 AM
  3. Making a spreadsheet dynamic
    By holla in forum Excel General
    Replies: 4
    Last Post: 09-10-2009, 12:27 PM
  4. Making a dynamic list?!
    By mayerc in forum Excel General
    Replies: 2
    Last Post: 06-15-2006, 10:50 AM
  5. Making print range dynamic in macro
    By Newbie dumbo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2005, 06:50 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