+ Reply to Thread
Results 1 to 3 of 3

How can I create a range in Column B based on repetitive values from Column A?

  1. #1
    Registered User
    Join Date
    09-10-2018
    Location
    Ca, United States
    MS-Off Ver
    2016
    Posts
    1

    Angry How can I create a range in Column B based on repetitive values from Column A?

    1 1 Here is what my data looks like. I am trying to create a code that identifies all the rows with the same values in column A, and then
    1 3 finding the MAX-MIN within column B of those rows. I am a beginner to VBA and this has been frustrating me for the past two days, plz
    1 4 help !!!
    1 2
    1 3
    1 2 For example - Within all rows with "1" in Column A. The MAX is 5, and MIN is 1 for column B therefore the range is 4.
    1 2 - Within all rows with "2" in Column A. The MAX is 7, and MIN is 2 for column B therefore the range is 5.
    1 3 - Within all rows with "3" in Column A. The MAX is 9, and MIN is 3 for column B therefore the range is 6.
    1 3
    1 5
    2 6
    2 6
    2 7
    2 3
    2 2
    2 3
    2 4
    2 5
    2 6
    3 4
    3 3
    3 5
    3 7
    3 8
    3 9

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: How can I create a range in Column B based on repetitive values from Column A?

    I did this using two pivot tables.

    One to get the min and max values, and the second one uses the first pivot table as the source and uses a calculated field to subtract the min from the max.
    Attached Files Attached Files

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: How can I create a range in Column B based on repetitive values from Column A?

    It's pretty trivial using Power Query:

    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

+ 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] COUNTIF values in a column based on date range in another column
    By RichPee in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-03-2018, 11:48 AM
  2. [SOLVED] create range based on last row/last column
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2015, 07:44 AM
  3. Create new rows based on Multiple values in a column
    By bmj121 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2015, 03:17 PM
  4. Replies: 8
    Last Post: 05-02-2014, 08:54 AM
  5. Create Workbooks based on Unique Values from a Column
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2012, 04:25 AM
  6. VBA Macro to Create Sheets Based on Column of Values
    By chicagoland8 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2012, 11:39 AM
  7. Create Sheets based on unique values in Column
    By Hblbs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-20-2009, 08: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