+ Reply to Thread
Results 1 to 16 of 16

How to Reference a String in a Way Similar to the OFFSET function

  1. #1
    Registered User
    Join Date
    07-25-2016
    Location
    Provo, UT
    MS-Off Ver
    2016
    Posts
    7

    How to Reference a String in a Way Similar to the OFFSET function

    Hi, I'm trying to reference a cell in the same way that is possible using the OFFSET function, but I a want to return a string instead of a value. I am only trying to reference one cell's string at a time.

    In column A I have a series of strings, but in column B there are 5 rows that pertain to A1, 5 that pertain to A2, etc. I want to be able to copy and paste a formula in column B that will always reference the correct string in column A.

    Thanks!

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to Reference a String in a Way Similar to the OFFSET function

    1. It would help to see the workbook.

    You get better help on your question if you add a small excel file, without confidential information.

    Please also add manualy the expected result in your file.

    To Attach a File:

    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to Reference a String in a Way Similar to the OFFSET function

    It sounds like you have something like this:

    Data Range
    A
    B
    1
    String1
    String1-1
    2
    String1-2
    3
    String1-3
    4
    String1-4
    5
    String1-5
    6
    String2
    String2-1
    7
    String2-2
    8
    String2-3
    9
    String2-4
    10
    String2-5


    However, what you want to do with that is unclear.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    07-25-2016
    Location
    Provo, UT
    MS-Off Ver
    2016
    Posts
    7

    Re: How to Reference a String in a Way Similar to the OFFSET function

    Alright, I've attached the result I want, I am hoping to make it so that the cells in the second column automatically know how to reference the right string in the first column. Thanks!
    Attached Files Attached Files

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to Reference a String in a Way Similar to the OFFSET function

    Try

    =INDEX($A$2:$A$4,CEILING(ROWS($1:1)/5,1))&" - "&MOD(ROWS($1:1)-1,5)+1

  6. #6
    Registered User
    Join Date
    07-25-2016
    Location
    Provo, UT
    MS-Off Ver
    2016
    Posts
    7

    Re: How to Reference a String in a Way Similar to the OFFSET function

    So far that returns "String 1 -1" every time, doesn't matter which cell I paste it into.

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to Reference a String in a Way Similar to the OFFSET function

    Right, the first one will be String 1 - 1

    When you then Fill it down, it will incriment
    So in the book you posted, put that formula in B2, then Fill down.

  8. #8
    Registered User
    Join Date
    07-25-2016
    Location
    Provo, UT
    MS-Off Ver
    2016
    Posts
    7

    Re: How to Reference a String in a Way Similar to the OFFSET function

    Alright I apologize I need to be more specific. I'm working on a workbook that has certain patterns. In most of the sheets, a single row pertains to String 1. In other sheets, there may be several rows (eg. 5) that pertain to string 1. Once I get those 5 rows the way I want them, I want to be able to copy and paste them down so that they pertain to String 2. You can see what I mean in the file I uploaded. I feel like there should be a way to mathematically reference a cell, but have that reference change depending on where you are pasting the formula. I can easily do it with the OFFSET function, but the OFFSET function always returns a value and not a string.

  9. #9
    Registered User
    Join Date
    07-25-2016
    Location
    Provo, UT
    MS-Off Ver
    2016
    Posts
    7

    Re: How to Reference a String in a Way Similar to the OFFSET function

    Oops, here's the file
    Attached Files Attached Files

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to Reference a String in a Way Similar to the OFFSET function

    I don't understand how the formula I posted doesn't resolve that?

    That IS a mathematical pattern of every 5 cells.
    change the 2 5's in the formula to say 7, then it's every 7 cells.
    =INDEX($A$2:$A$4,CEILING(ROWS($1:1)/7,1))&" - "&MOD(ROWS($1:1)-1,7)+1

    You can put that # in another designated cell to change as you wish, say D1
    =INDEX($A$2:$A$4,CEILING(ROWS($1:1)/$D$1,1))&" - "&MOD(ROWS($1:1)-1,$D$1)+1

  11. #11
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to Reference a String in a Way Similar to the OFFSET function

    Don't use blah blah...at least not for every single cell.
    There is no way for me to know which string any cell on Second Sheet is supposed to refer to from the first sheet.

  12. #12
    Registered User
    Join Date
    07-25-2016
    Location
    Provo, UT
    MS-Off Ver
    2016
    Posts
    7

    Re: How to Reference a String in a Way Similar to the OFFSET function

    I pretty much just want the equivalent the OFFSET function, but where it returns a string instead of a value. I have a much better example of what I'm looking for in the file I have attached. I apologize I wasn't more clear before. I want to be able to copy and paste the formula the same way I can with the OFFSET function.
    Attached Files Attached Files

  13. #13
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to Reference a String in a Way Similar to the OFFSET function

    I'm sorry, I'm still confused.

    "But where it returns a string isntead of a value"...
    WHAT string? Where will that string come from?

    Here's the same file you just posted, but I replaced A1:A3 with Strings instead of numbers. Formula in column B is the same as you made it.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    07-25-2016
    Location
    Provo, UT
    MS-Off Ver
    2016
    Posts
    7

    Re: How to Reference a String in a Way Similar to the OFFSET function

    Thanks, in my more complicated workbook I was working on I had a zero returned, so I assumed that strings wouldn't work with the OFFSET function. Since they do, I'm good, thanks, sorry for the hassle!

  15. #15
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: How to Reference a String in a Way Similar to the OFFSET function

    You're welcome..

    If it's returning a 0, that indicates the cell ultimately being referenced is either actually 0 or Blank.
    Indicating that the 'Math' worked out to a cell that was beyond the scope of the original referenced data.

    You can wrap the entire formula in the T function to ensure it is returned as a TEXT string.
    So if the resulting value ends up as 0, it will be converted to a blank ""

    =T(OFFSET(A$1,(ROW()-1)/5,0,1,1))

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to Reference a String in a Way Similar to the OFFSET function

    Another way...

    =OFFSET(A$1,(ROW()-1)/5,0,1,1)&""

+ 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. Offset function with reference cell equal to the value of match function
    By cmurda in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-08-2014, 02:09 PM
  2. Replies: 16
    Last Post: 12-24-2012, 06:21 AM
  3. function similar to offset to offset the offset
    By Jerseynjphillypa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-03-2012, 03:07 PM
  4. Replies: 3
    Last Post: 04-07-2011, 06:45 AM
  5. Is there a function similar to Mid that also inserts in a string
    By Matija in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-15-2011, 06:14 AM
  6. Offset function isn't working - volatile reference
    By MrPez in forum Excel General
    Replies: 3
    Last Post: 08-20-2010, 05:12 AM
  7. OFFSET function with variable reference cell
    By smile2leksa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2009, 08:32 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