Excel VBA - Change Cell Contents Based On Dynamic Cell Range

jski21

Board Regular
Joined
Jan 2, 2019
Messages
155
Office Version
  1. 2016
Platform
  1. Windows
Good day Mr. Excel Team,

I have a dynamic database that grows as new information is added. The data entry folks don't understand the need for data consistency and I continually struggle with different cell contents for the same category of accounts. Seeking a way through VBA to change the contents of the name in Column D based on the content of what is in a cell in Column A. Example:

All_Balances_by_Major_Program (4).xlsx
ABCD
1AcctNoMajor ProgramMajor Program NameName
21961900119619Sample 1Sample 1 - 2024
Grant Balances


If the cell in Column A = 19619001 (A2), then the content in Column D of corresponding cell in that row for that entry (D2) would be changed to "Sample 1 - 2024".

The example above is just one instance. Unfortunately, I have several different instances of this for values in Column A so if it could cycle through the various instances that would be ideal. For example, in addition to the example above, the next instance might be:

If the cell in Column A = 123456078 (A2), then the content in Column D of corresponding cell in that row for that entry (D2) would be changed to "Sample 2 - 2025".


Hope this explanation is satisfactory. I hate data inconsistency.


Thanks all,

jski
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
You have not provided an explanation of how you get the descriptions from those numbers.
 
Upvote 0
You have not provided an explanation of how you get the descriptions from those numbers.
Thanks for the reply. The description in D2 is what I'd like to to be and not tied to any other source/database (yet). Loosely, I think the code might follow something like this?

For i = 2 To LastRow
If Range("A" & i).Value = "19619001" Then
Range("D" & i).Value = "Sample 1 - 2024"
End If
 
Upvote 0
Why don't you create a table and use XLOOKUP in Column D? It seems that you could new items to an Excel table and it would update automatically. Otherwise you're adding new code every time you have a new value.
 
Upvote 0
Why don't you create a table and use XLOOKUP in Column D? It seems that you could new items to an Excel table and it would update automatically. Otherwise you're adding new code every time you have a new value.
I've considered that but the changes are only a good-sized handful of historical data. I've somewhat got a handle on the new stuff coming in...turnover makes it challenging. Appreciate the consideration and advice. Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,798
Messages
6,181,038
Members
453,014
Latest member
Chris258

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top