VBA Help - Create a running log of values entered in a cell

wstbch

New Member
Joined
Jan 26, 2024
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone,

I have researched and found similar codes to achieve a version of what am I looking for, but my VBA skills are not sufficient to make it custom to my need.
(Apologies, I cannot post a mini-sheet as my work blocks addons)

Column A has a list of permanent sites. Column B is where I enter the most recent inspection. For a clear historical log, I'm trying to have every value entered into Column B pushed to the next column and so on and so on...
Is this practical? Or is there a more practical application of this concept that I have missed.
Thanks in advance for your help.
 

Attachments

  • Logbook.PNG
    Logbook.PNG
    22.2 KB · Views: 7

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
If I were doing it, I would use column B as the data entry column (same as you are doing), but then immediately move the data to columns C and beyond instead of overwriting column B each time. But that is just preference. There are ways to do it as you are describing, but it feels more tedious to do that, even if it is only a couple more lines of code.

Book1 (version 1) 1-25-2024.xlsx
ABCDE
1Site Inspection Log
2SiteInspectionMost Recent InspectionPrevious Inspections
3Site#11/1/202412/1/202311/1/2023
4Site#2
5Site#3
6Site#4
Sheet9


Date entered in column B is immediately moved to C and the rest is shifted to the right.
 
Upvote 0
That is a great solution. I tried to copy the min-table you inserted, but when I paste it into excel there doesn't appear to be code attached. What am I doing wrong?
 
Upvote 0
That is a great solution. I tried to copy the min-table you inserted, but when I paste it into excel there doesn't appear to be code attached. What am I doing wrong?
I have not provided any code yet. That was just an example of my idea. I will post code shortly.
 
Upvote 0
Insert the following code into the sheet module:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("B3:B6")) Is Nothing Then                '<--Update column B range here for as many sites you have.
    Target.Offset(, 1).Insert xlShiftToRight
    Range("C" & Target.Row()).Value = Range("B" & Target.Row()).Value
'    Range("C" & Target.Row()).Interior.Color = xlNone                  '<--use this line if column B has fill color you do not wish to transfer with the date.
    Range("B" & Target.Row()).ClearContents
End If
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,033
Members
449,092
Latest member
ikke

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