+ Reply to Thread
Results 1 to 6 of 6

Apply Macro for 1 row to all rows (it adds values from one set of columns to other set)

  1. #1
    Registered User
    Join Date
    11-05-2013
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    3

    Apply Macro for 1 row to all rows (it adds values from one set of columns to other set)

    Hi All:

    I have a macro that adds the values in three columns to three other corresponding columns in the same sheet. The macro then zeros out the columns from the first set (after the adding takes place) and also zeros out the date column associated with those values. This is the code (FYI: I am new to macros):

    Please Login or Register  to view this content.
    I have a TWO questions:

    First: Instead of zeroing out the date, I actually want the date to change to Date + 1 month -- how can I do that? (the K and X columns are the Date columns)

    Second, and most important: I want to apply this macro to ALL rows, not just the one -- how can I do that?

    For context (to the extent it helps), I have one spreadsheet that is tracking "life of file" spend (for litigation) as well as a quarterly spend that includes Hours, Fees and Costs (these are the three columns). At the end of each quarter, I want to be able to use the macro to add the quarterly spend (hours, fees, costs) to the associated "life of file" spend columns. I then want the quarterly spend column to zero out and have the date updated to the next month (first month of new quarter).

    Thanks in advance for any help here!!

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Apply Macro for 1 row to all rows (it adds values from one set of columns to other set

    Please try the below code.......

    Please Login or Register  to view this content.
    Here this code will run for row no.2 to the last row with data in column K. You can change these red colored values as per your need.

    I hope this helps.
    Last edited by sktneer; 11-05-2013 at 11:09 PM.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    11-05-2013
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    3

    Re: Apply Macro for 1 row to all rows (it adds values from one set of columns to other set

    Sktneer -- Thank you so much for sending this response, I really appreciate it. One question though, it is telling me that I have a variable not defined, it is the i in "For i = 2 to lr" -- any thoughts? Thank you again for this!

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Apply Macro for 1 row to all rows (it adds values from one set of columns to other set

    You can declare i variable just below the line Dim lr As integer. like

    Dim i As Integer

    And lr is already declared.

  5. #5
    Registered User
    Join Date
    11-05-2013
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    3

    Re: Apply Macro for 1 row to all rows (it adds values from one set of columns to other set

    Thank you so much Sktneer -- that worked perfectly!! Much appreciated.

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Apply Macro for 1 row to all rows (it adds values from one set of columns to other set

    You're welcome. Glad to help you.

+ 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. Macro to apply formatting to an unknown range of rows & columns
    By anya1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-19-2013, 09:07 PM
  2. Replies: 0
    Last Post: 12-22-2011, 03:42 PM
  3. Macro adds rows with values, not blanks
    By leaning in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-11-2011, 03:26 PM
  4. Help: Macro Adds Rows, Need to Update Totals with New rows
    By Matt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2006, 12:15 PM
  5. Help: Macro Adds Rows, Need to Update Totals with New rows
    By Matt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2006, 05:35 PM

Tags for this Thread

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