+ Reply to Thread
Results 1 to 3 of 3

How do i find first value and last value in 2 separate columns and store the values?

  1. #1
    Registered User
    Join Date
    02-25-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1

    How do i find first value and last value in 2 separate columns and store the values?

    Hi I have the following data:

    stock name month open price close price
    A Jan 21.3 22
    A Feb 23 21
    A March 19 23.5
    A Dec 24 26
    B Jan 3 3
    B Feb 4 5.5
    B March 6 8.5
    B Dec 11 11.5

    How would i get the first value for open price and the last value for close price for each stock using excel vba? For example, stock name A has an open price of 21.3 and a close price of 26 for the full year. The data is already sorted by stock name and month. I have thousands of stock values and need to do it for each one.
    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,167

    Re: How do i find first value and last value in 2 separate columns and store the values?

    Hi xlrv and welcome to the forum,

    Instead of using VBA, how about a Pivot table to filter our the other months and only show Jan and Dec. I suggest this because, if you would have used dates instead of month name text, you would have an easy time sorting your data. When you use month names, sorting from earliest to latest is much harder.

    See the attached for a suggestion on a non VBA method.

    Jan and Dec Open Close prices.xlsm
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How do i find first value and last value in 2 separate columns and store the values?

    Just filter you raw data by Jan & Dec

+ 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. Store Cell Input in Array (separate worksheet, "comma" as separator between values)
    By jhoelski in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-23-2017, 12:45 AM
  2. Replies: 1
    Last Post: 04-19-2013, 08:30 PM
  3. Find duplicate values based on 2 separate columns
    By dreich in forum Excel General
    Replies: 1
    Last Post: 01-30-2013, 01:41 AM
  4. Search, find, store values as variables
    By jasondu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2012, 02:32 PM
  5. [SOLVED] Store Column A & B values in separate arrays for every unique value in Column A
    By tenscourts in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2012, 09:53 AM
  6. Copy columns values into separate columns
    By Mike_can in forum Excel General
    Replies: 7
    Last Post: 05-26-2006, 07:35 PM
  7. [SOLVED] Store Macros in separate Fiel
    By Plinkerton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-03-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