+ Reply to Thread
Results 1 to 5 of 5

Vba to set cells equal to these values

  1. #1
    Registered User
    Join Date
    06-11-2013
    Location
    Indiana, PA
    MS-Off Ver
    MS365 Version 2209
    Posts
    19

    Vba to set cells equal to these values

    Hello,

    I've attached a worksheet. I want a button that resets all of these cells to the values that currently live in them, no matter the edits to any of them, up to the point of clicking the button.

    The range of data is C6:V434, but there are cells in between these points that have formulas in them, so I can only effect the cells in the attachment that have values in them.

    Is there a way to more easily write this than referencing every cell and writing the code to set each cell equal to the respective value? There are 1746 datapoints on the spreadsheet and I can't imagine doing that.


    I really appreciate any help or advice that you can offer!


    Thank you,

    Will
    Attached Files Attached Files
    Last edited by billbalint; 03-05-2023 at 09:23 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Vba to set cells equal to these values

    Hello.
    The only thing that is understood from your description is that you have 1746 values in the sheet.

    So you should explain "much better" what you mean by "resets all these cells to the values that currently live in them".

    Four or five concrete examples would help to understand it, that is: I have "this" and I want to obtain "this other",
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  3. #3
    Registered User
    Join Date
    06-11-2013
    Location
    Indiana, PA
    MS-Off Ver
    MS365 Version 2209
    Posts
    19

    Re: Vba to set cells equal to these values

    My apologies! Let me try to better explain.

    If I write any value over the attached values, clear them, or make any changes to them, the button would return them to the original values that are in the attachment.

    Example: If I change cell C6 from 10 to 25 and K33 from 99 to 50; I want the button to return the values to 10 and 99. Same goes for every cell where there is data in my attachment. Say that I delete the value in R18. The button would bring back the 10000, that is there, in the attached. The attached values are my "default" values. A user can toggle all of the values. Once they toggle them, I want a master button to reset them to what is in the attachment.

    I hope that better explains what I need.

    I really appreciated it!

    Will

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Vba to set cells equal to these values

    Does it look like "undo" button?
    This is first idea:
    1- Copy the "Sheet1" into 1 backup sheet "Sheet1b"
    2- The "Undo" button will copy/paste the old value in Sheet1b back
    Is it are you looking for?
    Quang PT

  5. #5
    Registered User
    Join Date
    06-11-2013
    Location
    Indiana, PA
    MS-Off Ver
    MS365 Version 2209
    Posts
    19

    Re: Vba to set cells equal to these values

    I actually solved this. I did it by writing the code for one column; column C, and then just manipulated the code I had written for column C with Find/Replace, for each other column.

    Column C, cell 6 has a default value of 10.

    The code for that cell is:

    Range("C6").Value = 10


    Continued for more context:

    Range ("C7").Value = 5
    Range ("C8").Value = 3
    Range ("C11"). Value 10

    All the way down to the end of that data in column C.


    Same for column G, H, I ect....



    G6, F6, etc...


    Thank you all for your help!

    Will

+ 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. How to equal two cells if they have different values
    By mariosex in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-10-2018, 05:55 AM
  2. Multiple Cells values - formula to see which cells added together equal zero?
    By rodders0223 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-15-2013, 11:09 AM
  3. If cell values equal, then merge cells
    By TonyforVBA in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-01-2013, 01:19 AM
  4. [SOLVED] Compare iF cells has equal values then.............
    By Oceans in forum Excel General
    Replies: 9
    Last Post: 11-07-2012, 09:13 AM
  5. [SOLVED] If cells Values are equal..........then
    By Oceans in forum Excel General
    Replies: 2
    Last Post: 11-07-2012, 05:47 AM
  6. Matching cells with equal values
    By LukeBhatia in forum Excel General
    Replies: 4
    Last Post: 09-14-2011, 11:19 AM
  7. checked the equal values from cells
    By kar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2006, 04:48 PM

Tags for this Thread

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