• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

How to not overwrite a cell on an IF condition|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / How to not overwrite a cell on an IF condition|General Excel Questions & Answers|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumGeneral Excel Questions & Answe…How to not overwrite a cell on an I…
sp_PrintTopic sp_TopicIcon
How to not overwrite a cell on an IF condition
Avatar
William Adkins
Member
Members
Level 0
Forum Posts: 18
Member Since:
May 28, 2021
sp_UserOfflineSmall Offline
1
June 9, 2021 - 4:44 am
sp_Permalink sp_Print

I need to preserve a value in a cell based on the results of a conditional statement. Here is an outline of the problem.

I have a source table with a text column of 'check' values for the conditional validation. In the same table is a column of numeric values to be placed in the target cell in the target table. The goal is to overwrite or initially load the target cell if the AND is TRUE. However, if it is not true I get the existing value set to 0 which is not what I need. I am trying to keep history across status types. The file shows it more clearly. So here is the run down:

Base Data:

Status      Days in Status

'Ready'          11

Target table:

Column for Status       'Ready'

Value of Days in Status  11 

If condition for loading to Value of Days in Status in target table: 

=IF(AND(Data!E8="Ready",Data!I8>0),Data!I8,<<<<What can go here to preserve the existing cell value?>>>>)

Presently there is a value of '0' in the FALSE condition so that the IF will work for demonstration purposes.

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 871
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
2
June 9, 2021 - 3:48 pm
sp_Permalink sp_Print

Hello,

In your sample file you write that in cell E5 you want the number three if the condition is false, but where does this three come from? Is it based on a calculation or is it just a fixed number?

As shown in your sample file, I can’t figure out what the problem is, if you want number three to be shown, put in that number.
I also recommend you to not have the TODAY() function in every row of your table, as the data grows you risk to get longer loading/updating time. Put it instead in a single cell outside the table.

Br,
Anders

Avatar
William Adkins
Member
Members
Level 0
Forum Posts: 18
Member Since:
May 28, 2021
sp_UserOfflineSmall Offline
3
June 9, 2021 - 9:28 pm
sp_Permalink sp_Print

Anders,

Thanks for the response. Here is the flow of data for E5 and all other cells in the tblStoryTracking table.

Day One: The Status say for the Data cell Data!E8 = "Ready" that gets us to the needed column. ID 'aa' is the 'link' if you will between Data and tblStoryTracking. At that point the value of Data!I8, a 3, should be placed in the E5 cell.

Day Two: Data!E8 is now "Design", the project has moved on to  the next stage. The ID is still 'aa'. The new value in Data!I8 would be a 1 as the project has only been in that status one day and goes into E6. There is no new value for E5, I want E5 to stay 3 has a historical value as the project continues to move forward. I want each cell in row E, and all of the other cells to retain their old values as we move through the phases of the project.

We are tracking the time that the project stays in each phase to determine if there is too much time being spent in a given phase (status). This is then displayed, everyday in a stacked bar chart to give us the cycle trend on each project over time.

Hopes this help provide some clarification.

Additionally:

The use of TODAY is to calculate the time elapsed between the update date and the current day, the table in Data never gets very big, usually no ,ore than 150 rows max. This gives us the values in I8:I30. As these dates, and the subsequent Days value change the appropriate cell in tblStoryTracking, say E5 for example, is updated to the new day value if E8 Status is a match, I.E. from 1 to 2 to 3 etc. with the final value needing to be preserved as discussed above.

It is messy but necessary as this is a KPI for the projects.

 

William

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 871
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
4
June 10, 2021 - 5:34 am
sp_Permalink sp_Print

Hello,

I am sorry, but I can't follow your steps with the sample file you have attached.
For example, in sheet Data, cell E8, the value is todays date. Cell I8 has no value, it is blank.
The id for row 8 is dd, not aa.

I also don't follow with why you compare the update date against todays date, unless you of course update the date in that column, but then how do you keep track of when the status changes occured?

I suggest you use tabular data setup in your tblRaw, thus adding a new row for each status change, which gives you the possibility to keep track of when the status changed for each ID. Not sure if this is in line with what you want to see, it is however what I think (assume) you want. See attached file for an example.

Br,
Anders

Avatar
William Adkins
Member
Members
Level 0
Forum Posts: 18
Member Since:
May 28, 2021
sp_UserOfflineSmall Offline
5
June 10, 2021 - 10:15 pm
sp_Permalink sp_Print

Anders,

Apologies for the horrible example, I realize I was looking at another Excel worksheet. So let's start from the beginning so that things might make a bit more sense.

1) A project changes status over time, as you have seen. Analysis to Ready to Design, etc.

2) A project will spend N number of days in a state, form 1 - N.

3) The Update is the date that the project entered the current status.

4) The number of days that the project has been in a given status is Days(Delta)= TODAY - Update date.

5) The desired reporting number is the Days.

6) The needed grouping is project (vertical axis) by Status(horizontal axis).

This data is then used for stacked bar charts and scatter plots to determine where the project is spending the most time so that we can adjust the flow of work.

So lets go back to the original spread sheet explanation and use the correct cell id's. By way of illustration there are two sets of example tables to capture the before/after effect. The process is the same for both sets so the flow examples are valid.

In the attached file here is the hypothetical flow:

Starting with table Sample 1 as the Base table, target example table tblStoryTracking 1

Day One: The Status say for the project 'aa' (Data!Cell B5) is in "Ready" state shown in Data!Cell C5 the calculated Days (Data!G5) is say '11', for the example. In tblStoryTracking 1 table this is what happens: we match Data!B5(Project) to Cell C5 and Data!C5 (Status) to Column "Ready" in the Story Tracking table. We populate Cell E5 with the Calculated Days from Data!G5. In tblStoryTracking 1 we now have '11' in Cell E5.

So now tblStoryTracking 1 looks like this:

ID      Analysis     Ready     Design

aa           0            11            0

Day Two: Say that Status Data!B9 for project 'aa' is now "Design", the project has moved on to  the next stage. The ID is still 'aa' but we now have a new Days value in Data!G9, '1'. This new value (Data!G9, Days) is loaded to the tblStoryTracking 2 table we follow roughly the same process we match Data!B9(Project) to Cell C9 and Data!C9 (Status) to Column "Design" in the Story Tracking table. We populate Cell F9 with the Calculated Days, '1', from Data!G9. 

Now here is the issue:

Continuing with table Sample 2 (Data) and the base table and target example table tblStoryTracking 2

When the project changed status from "Ready" to "Design" the value in Cell E9 was changed to '0'. And the 'Design" Cell F9 changed to '1', as shown below:

So now tblStoryTracking 2 looks like this:

ID      Analysis     Ready     Design

aa           0            0            1

I need to keep the '11' located in Cell E5(E9) for historical tracking purposes. This is the issue, how do I keep that value in Cell E5(E9) from being flipped to '0' because the value in Data!C9 is no longer "Ready" but has change to "Design"(Data!C9,in Sample 1). I have tried all sorts of twists and turns using IF/AND/OR/NOT/IFS and no solution as yet. Each cell in tblStoryTracking 1/2 is an IF/AND statement as you can see when you select one of the cells.

I hope that this explains the situation better.

William

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 871
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
6
June 11, 2021 - 6:27 am
sp_Permalink sp_Print

Hello,

Thanks for the new sample file. Just wondering, did you check the modified sample file I uploaded in my previous post? I am asking because with that approach you can get what you want, just modify it so you check against todays date. If you want to only have one row per ID and only have one status and update column then you need to involve VBA to do the days calculations and write the value to correct cell in tblStoryTracking.

With a table where you add a new row for each status change you then keep track of when the status changed and can look it up and do needed calculations.

Br,
Anders

Avatar
William Adkins
Member
Members
Level 0
Forum Posts: 18
Member Since:
May 28, 2021
sp_UserOfflineSmall Offline
7
June 12, 2021 - 12:24 am
sp_Permalink sp_Print

Anders,

Yes I did review the workbook you sent. Our issue with that method is that our data comes from a tool and we have only a single entry per project with current status and the last project update date. So we are stuck with the data organization you see in the first worksheet. I have a feeling that this will indeed call for a VBA script. If nothing else for the sake of sanity as I have tried a host of IF's in various forms, learned a lot about IF's and limitations so it has not been a complete waste.

I will need to get some tutorials on VBA syntax and structure so I can do this. I have not coded in almost 20 years so this should be very interesting :-).

Thanks for all you help with this,, it is appreciated.

William

Avatar
William Adkins
Member
Members
Level 0
Forum Posts: 18
Member Since:
May 28, 2021
sp_UserOfflineSmall Offline
8
June 12, 2021 - 9:26 pm
sp_Permalink sp_Print

Anders.

Figured it out. It was actually simple, horribly so, with the following IF in the target cell.

B14 contains: =IF(Data!$E16="Analysis", IF(Data!$I16>B14,Data!I16,),B14) all that was needed was to place the 'B14' as the false action on the Status check. This IF is far simpler than the one I started with as well. Still have some glitches with fighting a circular reference, underlined in the example as well, it but that is for another thread. 

Thanks again.

 

William

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online:
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
stuart burge
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27295

 

Member Stats:
Guest Posters: 49
Members: 31920
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.