+ Reply to Thread
Results 1 to 9 of 9

Need VBA Script To Calculate Totals For Inventory Report

  1. #1
    Forum Contributor
    Join Date
    01-29-2015
    Location
    .
    MS-Off Ver
    2010
    Posts
    313

    Need VBA Script To Calculate Totals For Inventory Report

    Attached is an inventory report I run out of SAP. Column A contains the storage location numbers for each part number(Column H). I would like to create a macro that calculates the total for all storage locations. The issue I have is that the number of storage locations is constantly changing. The totals are in column B in the same row the part number and part information is listed. Can someone help me?
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,209

    Re: Need VBA Script To Calculate Totals For Inventory Report

    Hi Scarlett,

    Before I start playing with this, why is row 7 between the Before and After sheets different?

    Second. Does it need to look exactly like your "After" sheet?

    Third. What do you need to know from the after sheet? What questions do you answer from the after?

    Forth - Did you see the grand totals at the bottom of the before and after aren't equal? Is this different data?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need VBA Script To Calculate Totals For Inventory Report

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need VBA Script To Calculate Totals For Inventory Report

    So I'm hoping your before and after are two different reports? Because none of the values seem the same. I'm assuming you just wanted to show examples of the formatting you wanted. Also the before sheet is shifted over one column from the after. I didn't alter that with my code, but we certainly could.

    Please Login or Register  to view this content.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,209

    Re: Need VBA Script To Calculate Totals For Inventory Report

    Hi John,

    I read your code with great interest. I'm curious where you learned your VBA.

    I've never seen the (3) (-2) at the end of a range selection statement before as in this line:
    x = Range("C" & Rows.Count).End(3)(-2).Row

    Also it was very interesting to see a ".Areas" work down the columns as I'd not seen that before.

    Last I hadn't seen the Address(False, False) syntax used in any code before either.

    I've only seen one other person use the first of the examples above. Where did you get your VBA training? There may be lots I'm missing in my education.

  6. #6
    Forum Contributor
    Join Date
    01-29-2015
    Location
    .
    MS-Off Ver
    2010
    Posts
    313

    Re: Need VBA Script To Calculate Totals For Inventory Report

    The code I tried didnt work. It gave me an error at the"For Each numrang In..." Row. Marvin, I am attaching a revised spreadsheet. I must have made a mistake
    Attached Files Attached Files

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,209

    Re: Need VBA Script To Calculate Totals For Inventory Report

    Hi Scarlett,

    The new .xls file attached has no blank row at the top. It also has no before and after sheets. What I'm really looking for is what your SAP dump looks like and what you need to know or calculate from it. I'm thinking a pivot table would be most useful but don't want to start on it until I know what problem you're trying to solve. I also need to know if it needs to look exactly like your After sheet.

  8. #8
    Forum Contributor
    Join Date
    01-29-2015
    Location
    .
    MS-Off Ver
    2010
    Posts
    313

    Re: Need VBA Script To Calculate Totals For Inventory Report

    Thank you so much everyone!!! The last macro is just what I needed!!!!!!

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need VBA Script To Calculate Totals For Inventory Report

    @ MarvinP - I've learned from reading some, but most of what I've learned was from Forums, and Googling to solve problems.

    x = Range("C" & Rows.Count).End(3)(-2).Row (3) - is a shorter version of (xlUp), (-2) is a row offset
    .Address(False, False) - it removes the dollars signs in the code.

    @ scarlett: You change columns from your original sample.

    Maybe:

    Please Login or Register  to view this content.

+ 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. Inventory Report
    By pakhare.kiran in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2013, 07:30 AM
  2. negative inventory by Day, keep previous day's totals
    By swiftrain in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-26-2012, 02:51 PM
  3. [SOLVED] Inventory code to remove duplicates and sum totals
    By Chilisauce in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2012, 11:41 AM
  4. inventory report
    By gnettenstrom in forum Excel General
    Replies: 3
    Last Post: 04-03-2011, 12:45 PM
  5. [SOLVED] Is there a template that calculates inventory totals?
    By rcyphert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-04-2005, 12:06 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