+ Reply to Thread
Results 1 to 3 of 3

Offset formula references (only active sheet's)

  1. #1
    Registered User
    Join Date
    03-29-2018
    Location
    Ljubljana
    MS-Off Ver
    2013
    Posts
    2

    Offset formula references (only active sheet's)

    Hello,

    In my Excel I'm transposing large set of data and I need to keep references as they were before transposing. For this I need following:

    I want to offset references in formula in my VBA code, doesn't matter if absolute or relative, but offset only references that are on current sheet. References to other sheets should remain as originaly were.

    Example:

    = A1 + $B$1 + KF1001 + SUM(C2:C5) + sheet2'SUM(C2:C5)

    I have offset (3,2)

    Result should be

    = C4 + $D$4 + KH1004 + SUM(E5:E8) + sheet2'SUM(C2:C5)

    Can somebody help me with coding? I'm stuck.

    Thank you, Grho

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Offset formula references (only active sheet's)

    I would like to get a more detailed description of the overall problem you are trying to solve, because I suspect that using VBA to modify worksheet formulas to apply an offset is not the best way solve your overall problem. Parsing and modifying worksheet formulas in VBA is certainly possible but more complicated than meets the eye and I'll bet if we start from the beginning we can get you a better solution.

    It would especially help if you attach your file: The paper clip icon does not work for attachments. Instead, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-29-2018
    Location
    Ljubljana
    MS-Off Ver
    2013
    Posts
    2

    Re: Offset formula references (only active sheet's)

    Hello,

    Thank you for answer.
    OK, I attached a test example, but you will get the idea. The final solution is a sales budget simulation/planning solution with close to 1000 people and 12 salary subitems.

    In the attached excel, in Salary sheet is the data. With macro Trasform(2) I trasnspose this data to Sheet Final. The column G:G is the tricky one and in the test example I just manualy fixed the formulas (although in real case there are some more).
    I also started bulidling macro Testing(), to parse/transpose formula (this macro will finaly be a function in Trasform(2)). My idea was to parse references, then offset them accordingly, and then REPLACE the original references in formula with offseted ones.

    One problem is that my regex is still not OK parsing references that point to other sheet. But more concerning is, that if I pass the REPLACE on formula string, and the references in formula will point on the sheet and the same also on the other sheet, I will do the wrong replacement (because the reference to other sheet must stay the same as original).

    So I'm looking for some more clever approach to solve this formula offseting.

    I hope I was clear enough.

    Thank you for help.

    G
    Attached Files Attached Files
    Last edited by Grho; 03-30-2018 at 05:56 AM.

+ 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. Replies: 1
    Last Post: 08-26-2016, 12:38 PM
  2. Replies: 3
    Last Post: 12-12-2014, 02:42 PM
  3. [SOLVED] syntax to select cell in another sheet based on offset of active cell in current sheet
    By duvius in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-07-2014, 11:16 AM
  4. [SOLVED] save active sheet in new workbook, naming it as cell value of active sheet
    By arkharova.s in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-18-2014, 06:16 AM
  5. [SOLVED] Formula with offset from active cell and sum until blank cell
    By ArnolddG in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-27-2013, 03:15 PM
  6. Copy from active sheet and paste into new sheet using info from cell in active
    By Ingve in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2006, 06:00 PM
  7. [SOLVED] Creating absolute references including active sheet name in the formula
    By Maria J-son in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-10-2005, 04: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