+ Reply to Thread
Results 1 to 6 of 6

macro for a range of values

  1. #1
    Registered User
    Join Date
    10-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    macro for a range of values

    hi all,
    i want to write a macro for the following:
    - where does value in cell x fall within a specified range (Range of values and text.xlsx) and assign the appropriate text value.

    An example, a value of 168.75 = W; a value of 168.749 = WNW

    I could write a rather large series of IF functions but this seems rather labour intensive so I am hoping someone here can provide an easier solution?

    Best regards,
    Michael
    Last edited by cuzza_fin; 10-17-2013 at 09:08 PM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: macro for a range of values

    An example, a value of 168.75 = W; a value of 168.749 = WNW
    Really I am unable to understand the logic from the above example


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    10-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: macro for a range of values

    Maybe this will help. For the the values below, 168.75 is the middle value between true east (E) and east-north-east (ENE) and so on...
    Number Text
    -180 E
    -168.75
    -157.5 ENE
    -146.25
    -135 NE

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: macro for a range of values

    I would suggest you build a table of values and directions. Then use VLookup to evaluate where your data lies in the table. As a point of interest, I always thought that 180 degrees was due south and 90 degrees was due east.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: macro for a range of values

    Try this in a cell
    Please Login or Register  to view this content.
    E2 being the cell with the value you are looking for.
    It will give you the closest match for those that have no text value
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  6. #6
    Registered User
    Join Date
    10-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: macro for a range of values

    nice work alansidman and sean, I rarely use vlookup, thanks again.
    re alansidman: you are correct re angle and direction but for the angles generated in arcgis I am after the opposite direction and switching them around is the easiest solution

+ 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. Need help making a macro to copy range of values based on cell values.
    By zolton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-23-2013, 08:58 AM
  2. [SOLVED] Macro to repeat values in range
    By maroni in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-15-2013, 11:57 AM
  3. Replies: 0
    Last Post: 10-23-2012, 01:50 AM
  4. Adding a range of values with a macro
    By BFinn in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-31-2011, 05:10 PM
  5. Macro Loop to Extract Specific Values and Min/Max Values From Column/Rows Range
    By ExcelQuestFL in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-19-2010, 09:19 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