+ Reply to Thread
Results 1 to 5 of 5

Is it even possible to do that?

Hybrid View

mohamed hatem Is it even possible to do... 07-26-2024, 02:21 PM
JohnTopley Re: Is it even possible to do... 07-26-2024, 03:52 PM
mohamed hatem Re: Is it even possible to do... 07-28-2024, 10:32 AM
AliGW Re: Is it even possible to do... 07-28-2024, 10:37 AM
mohamed hatem Re: Is it even possible to do... 07-28-2024, 03:35 PM
  1. #1
    Registered User
    Join Date
    07-26-2024
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    3

    Is it even possible to do that?

    hello so I am trying to make a system that links a cell lets call it "Total cell General" with multiple cells where they resemble a year like for example (Total cell for 2023),(Total cell for 2024) etc but the catch is that the catch here I will link the total cell General with the total cell of each year and I want it to look the data from each year for example we are in the year 2023 so I write the following data in the total cell General "500" and it will be linked to the year 2023 so the Total cell for 2023 will have the data "500" and I want it never to be changed even after I change the cell Total cell because when 2024 comes I will change the Total cell General again for example to 900 to add the data for 2024 so i want the data in 2023 to remain 500 even after changing the total cell General to 900
    i know it sounds complicated but i am asked to do a system like that for my boss but i don't believe that it is possible i mean its not like an array in a programing language were it can save multiple data with the same variable but still if anyone knows a way i will really appric

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,979

    Re: Is it even possible to do that?

    You will need VBA for this.

    Fast answers need clear examples.

    Post a small Excel sheet (not a picture) showing realistic & representative sample data WITHOUT confidential information (10-20 rows, not thousands...) and some manually calculated results. For a new thread (1st post), scroll to Manage Attachments, otherwise scroll down to GO ADVANCED, click, and then scroll down to MANAGE ATTACHMENTS and click again. Now follow the instructions at the top of that screen.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Registered User
    Join Date
    07-26-2024
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    3

    Re: Is it even possible to do that?

    so I tried to make the example as simple as possible, in the following Excel, I want it so that when I input in the cell called Main cell once it only saves the date in the cell called 1st cell and nowhere else, and when I change the cell named Main cell again it changes the data for the cell called 2nd cell then do the same for the 3rd cell and 4th, etc... in the following example I changed the Main cell to 12 and it changed all the cells which aren't want I only want it to change the first cell than when I change it again it changes the 2nd cell but without losing the 1st cell value
    Untitled.png
    well I posted both a screenshot and the Excel cuz its a very simple idea but its hard to execute example.xlsx
    Last edited by mohamed hatem; 07-28-2024 at 10:38 AM.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,301

    Re: Is it even possible to do that?

    Everything is 12 and there's no source data in the workbook. There's not a lot of hope of our helping you without some idea of the source data that needs to feed these cells.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    07-26-2024
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    3

    Re: Is it even possible to do that?

    Well i got these 2 codes from ChatGPT but I keep getting an error after trying to input for the second time can you help me find the problem?
    So for the module code here it is
    ------------------------------------------------------------
    Dim changeCount As Integer
    Dim isConfirmed As Boolean
    Dim lastMainCellValue As Variant

    Sub ConfirmChange()
    Dim mainCell As Range
    Set mainCell = Range("A1") ' Main Cell address

    ' Debugging messages to trace the flow
    Debug.Print "ConfirmChange called"
    Debug.Print "isConfirmed: " & isConfirmed
    Debug.Print "changeCount: " & changeCount
    Debug.Print "lastMainCellValue: " & lastMainCellValue
    Debug.Print "mainCell.Value: " & mainCell.Value

    ' Only proceed if confirmation is not already done
    If Not isConfirmed Then
    changeCount = changeCount + 1
    Select Case changeCount
    Case 1
    Range("B1").Value = mainCell.Value ' 1st Cell
    Case 2
    Range("C1").Value = mainCell.Value ' 2nd Cell
    Case 3
    Range("D1").Value = mainCell.Value ' 3rd Cell
    ' Add more cases if you have more cells to change
    Case Else
    changeCount = 1 ' Reset count if it exceeds the number of cells
    Range("B1").Value = mainCell.Value ' Start over with the 1st Cell
    End Select
    isConfirmed = True ' Confirm the change
    MsgBox "Change confirmed for Main Cell value: " & mainCell.Value
    Else
    MsgBox "Please change the Main Cell before confirming again."
    End If
    End Sub
    -----------------------------------------------------------------------------------
    And for the button code to confirm here it is
    --------------------------------------------------------------
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim mainCell As Range
    Set mainCell = Range("A1") ' Main Cell address

    If Not Intersect(Target, mainCell) Is Nothing Then
    ' Check if the value of the Main Cell has actually changed
    If mainCell.Value <> lastMainCellValue Then
    isConfirmed = False ' Reset the confirmation flag
    lastMainCellValue = mainCell.Value ' Update the last known value
    End If
    End If
    End Sub
    -----------------------------------------------------
    but something isn't right I also sent the excel file

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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