+ Reply to Thread
Results 1 to 11 of 11

How to randomly choose a starting point but with a fixed data size from a column of data

  1. #1
    Registered User
    Join Date
    11-19-2015
    Location
    Albany NY
    MS-Off Ver
    2010
    Posts
    6

    How to randomly choose a starting point but with a fixed data size from a column of data

    I have a column of data (1300 data values) and need to to calculations based on randomly choosing a starting point amongst the data cells with a fixed end (lets say 100 cells).....the order matters......once I can retrieve the data points onto another column I can do my calculations. So for example, I need to have excel retrieve 100 data points in order of how they appear, but randomly starting at one of the cells in the column then going down 99 more cells....and place those 100 data points in other column for analytics. Anyone have a solution?

  2. #2
    Registered User
    Join Date
    11-18-2015
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    95

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    Hi! Check the VBA code in the file attached. I think the code performs the task that you need. Hope it helps!
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-19-2015
    Location
    Albany NY
    MS-Off Ver
    2010
    Posts
    6

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    I can't open the xlsm file on my work computer. Can you send so I can copy and paste?

  4. #4
    Registered User
    Join Date
    11-18-2015
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    95

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    Hi, this is the code:

    Please Login or Register  to view this content.
    Column A has the numbers, with a header in A1. In column B you get the results (also header in B1). Finally, a button to run the macro.

    ScreenShot.JPG

  5. #5
    Registered User
    Join Date
    11-19-2015
    Location
    Albany NY
    MS-Off Ver
    2010
    Posts
    6

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    I can't debug this portion
    Range("B1").Offset(X, 0).Value = Range("A1").Offset(StartPos + X - 1).Value

  6. #6
    Registered User
    Join Date
    11-18-2015
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    95

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    The code works fine on my computer. Download this version, may be you can open it an then save is as a file with macros.
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    Heres another one:

    Please Login or Register  to view this content.
    Ben Van Johnson

  8. #8
    Registered User
    Join Date
    11-18-2015
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    95

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    A shorter version taking into account protonLeah's contribution:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-19-2015
    Location
    Albany NY
    MS-Off Ver
    2010
    Posts
    6

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    Thank you so much excel_bat and protonLeah. It worked like a charm.

  10. #10
    Registered User
    Join Date
    11-18-2015
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    95

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    Great!

    If my answer helped you, please consider to add some reputation by clicking the star below this post! Thanks!
    excelbat.com: free Excel tools, macros...

  11. #11
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to randomly choose a starting point but with a fixed data size from a column of da

    There is a way with a formula to solve this. Values are in column A from A1:A1300

    1. Enter this formula in E1 (you can use any cell you like just change the references accordingly) To give you a random reference from which to start. 1201 is the last cell available if you want to have 100 cells with the last cell being A1300
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    2. Name the result of the above formula START.

    3. In the Name Manager amend the definition for START to this =INDIRECT(Sheet1!$E$1)

    4. Select a column of 100 cells

    5. Enter this formula (with the cells selected)
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    All the values from the start point to the end point will be filled in.

    To keep the values from changing (this is volatile) copy the range of 100 and then Paste Values where you want static values to work with.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ 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. VBA Usefrom Combo Box: Select starting point of drop down data
    By B Eccles-Williams in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2014, 06:42 PM
  2. Using Find or Search to extract data starting point from a formula
    By mike_vr in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-08-2014, 12:31 PM
  3. [SOLVED] VBA to copy data using 'Yes' as a starting point
    By kenadams378 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 05-28-2013, 06:30 AM
  4. Data Validation - Can I change the starting point?
    By FSUdawg85 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-28-2013, 09:54 AM
  5. Replies: 2
    Last Post: 06-27-2011, 10:47 PM
  6. Replies: 3
    Last Post: 06-12-2006, 11:30 PM
  7. Delete every 2nd column from fixed starting point
    By Darin Kramer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2006, 06:20 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