+ Reply to Thread
Results 1 to 4 of 4

How to make a large code by using a reference cell?

  1. #1
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    How to make a large code by using a reference cell?

    Hi,

    The question is basically the title, however, let me make it more clear.

    Let's say that you have a program of 10 lines that refer to several cells that should be copied and pasted back and forth. That program is related to a button.

    So, let's say that you should have 20 buttons that do basically the same but refers to different cells, meaning that the program is identical to the other but instead of refering to cells in the 20, 21, 22, 23 row, they are refering to cells in the 32, 33, 34 row.

    Meaning that the program is similar, but the job of changing all the reference points to the 10 lines for each button will be a big job.

    So, by solving this, I think that refering to one reference cell in the form of "Range("B2")" and then use this point as a reference and offset the other cells from this one.

    Any idea how to do this?

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

    Re: How to make a large code by using a reference cell?

    Please re-read the banner at the top of this page.
    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

  3. #3
    Registered User
    Join Date
    01-11-2020
    Location
    Norway
    MS-Off Ver
    Microsoft Office 2019
    Posts
    74

    Re: How to make a large code by using a reference cell?

    Ok, will do!


    E.G:

    Please Login or Register  to view this content.
    So, imagine the code above has the same cells on the right side of the equal sign (sheet2). But the cells on the left side are changing for each button that I want to set the code to.

    Meaning that all the cells are at same relevant distance to "A1" at "Sheet1", but they would be placed different on the sheet so I basically should be able to copy the right side of the code, get a reference point on the top cell at "sheet1" and then offset all the other cells downwards in the code.

    Does that make it clearer?

    Thanks for the reply btw!

  4. #4
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: How to make a large code by using a reference cell?

    Maybe you want something like this:
    Please Login or Register  to view this content.
    Cheers
    Erwin
    I started learning VBA because I was lazy ...
    Still developing.... being more lazy...

+ 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. [SOLVED] get cell reference from large formula?
    By vpan in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-10-2016, 05:37 PM
  2. [SOLVED] cell reference from LARGE result
    By jwarburton3 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-09-2015, 01:28 PM
  3. [Solved] How to make macros code reference data in open sheet
    By MontrealMTL in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2015, 06:23 PM
  4. Merge values into on large cell, but make dynamic
    By MMcGovern in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-22-2013, 06:13 AM
  5. Replies: 0
    Last Post: 03-08-2013, 06:34 AM
  6. [SOLVED] Cell Reference Problem with Offset and Large
    By zakkair in forum Excel General
    Replies: 11
    Last Post: 06-25-2012, 12:06 PM
  7. How to make a button VBA code reference other VBA code subroutines???
    By gunman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2005, 08:05 PM

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