+ Reply to Thread
Results 1 to 6 of 6

VBA Macro to Analyze Sales Data

  1. #1
    Registered User
    Join Date
    04-10-2014
    Location
    Scranton, Pennsylvania
    MS-Off Ver
    Excel 2013
    Posts
    3

    VBA Macro to Analyze Sales Data

    Hi,

    I have recently started trying to teach myself VBA. I don't have much experience using the language yet so I would love it if anyone could take a look at my code and tell me what I am doing wrong.

    I am trying to write a sub to analyze the theoretical sales data I created. For each region, if the sales increase for three consecutive quarters (Q4 > Q3 > Q2 > Q1), I want to fill the cell with the Region # in it green. Also, if the sales decrease for three consecutive quarters, I want to fill the cell with the Region # in it red.

    I have started writing the code but keep getting different error messages and am really stuck at this point. Any help would be greatly appreciated. Thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: VBA Macro to Analyze Sales Data

    Perhaps like this?

    Please Login or Register  to view this content.
    Alf

  3. #3
    Registered User
    Join Date
    04-10-2014
    Location
    Scranton, Pennsylvania
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: VBA Macro to Analyze Sales Data

    Thanks so much for the help, Alf!

    Your code helped a lot, but I'm still having one small problem. I only want the Region # in Column A to be highlighted in either green or red. I tried altering your code a bit to achieve this, but am still not having any luck. I'm not sure what I am doing wrong. Here is the code I have now:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: VBA Macro to Analyze Sales Data

    Replace

    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.
    As this macro uses a "For i = 2 To " statement you also need to add a "Next" to close the loop.

    Alf

  5. #5
    Registered User
    Join Date
    04-10-2014
    Location
    Scranton, Pennsylvania
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: VBA Macro to Analyze Sales Data

    Thanks so much for the help! I think I have a better understanding now.

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: VBA Macro to Analyze Sales Data

    You are welcome.

    Alf

+ 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. Useform which search the data of Primary sales and i can enter secondary sales data.
    By bipin_04 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-31-2013, 11:29 AM
  2. Replies: 4
    Last Post: 03-27-2013, 05:56 PM
  3. Macro to analyze and amend Data
    By Tao_ in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-10-2012, 11:16 AM
  4. [SOLVED] Macro to analyze the data
    By dobracik in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-25-2012, 03:54 PM
  5. [SOLVED] Macro to analyze the Raw Data
    By dobracik in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-12-2012, 02:52 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