Auto filling a cell in a table which has a list using data validation

rjn008

New Member
Joined
May 12, 2023
Messages
27
Office Version
  1. 365
Platform
  1. Windows
Good Afternoon,

Is it possible to auto populate a cell in a table where by the cell adjacent left has a format on it. The only issue I think I have is I use a list on the cell under data validation, but the list does contain the value I wish to have auto populated?

This is the mini sheet code and image of the style of sheet I am using;

The New LMS ^N4.xlsm
IJKLMNO
5Week 1Week 2Week 3Week 4Week 5Week 6Week 7
6ArsenalMan CityChelseaxxxx
7Man UtdNewcastle Utdxxxxx
8LiverpoolFulhamArsenalxxxx
9ArsenalMan CityChelseaxxxx
10ArsenalMan CityChelseaxxxx
11ArsenalMan CityBrentfordAston VillaLiverpoolAFC BournemouthWest Ham Utd
12ArsenalMan CityChelseaxxxx
13Newcastle UtdLiverpoolChelseaxxxx
14Man UtdMan CityBrentfordBrighton & HAxxx
15Newcastle UtdTottenhamChelseaxxxx
16ArsenalChelseaFulhamxxxx
17ArsenalMan CityChelseaxxxx
18Newcastle UtdTottenhamBrentfordBrighton & HAxxx
19Newcastle UtdLiverpoolArsenalxxxx
20ArsenalTottenhamBrentfordAFC Bournemouthxxx
21LiverpoolMan CityArsenalxxxx
22ArsenalMan CityChelseaxxxx
23LiverpoolTottenhamChelseaxxxx
24LiverpoolMan CityChelseaxxxx
25LiverpoolMan CityArsenalxxxx
26Newcastle UtdLiverpoolAston VillaBrighton & HAxxx
27ArsenalTottenhamChelseaxxxx
28Man UtdLiverpoolChelseaxxxx
29ArsenalTottenhamBrentfordBrighton & HAxxx
30Newcastle UtdTottenhamAston VillaMan UtdLiverpoolArsenalWest Ham Utd
31Man UtdFulhamNotts Forestxxxx
32Newcastle UtdTottenhamMan CityAston VillaMan Utdxx
33LiverpoolMan CityAston VillaBrighton & HAxxx
34ArsenalTottenhamAston VillaMan CityNewcastle Utdxx
35Newcastle UtdLiverpoolArsenalxxxx
36Newcastle UtdMan CityChelseaxxxx
37ArsenalMan CityBrentfordBrighton & HAxxx
38Newcastle UtdMan CityAston VillaMan UtdTottenhamArsenalChelsea
39Newcastle UtdLiverpoolAston VillaMan CityTottenhamChelseaArsenal
40LiverpoolMan CityFulhamxxxx
41Man UtdFulhamChelseaxxxx
42LiverpoolTottenhamBrentfordBrighton & HAxxx
43ArsenalChelseaAston VillaMan UtdLiverpoolMan Cityx
44ArsenalMan CityChelseaxxxx
45Newcastle UtdTottenhamChelseaxxxx
46Newcastle UtdLiverpoolChelseaxxxx
47Newcastle UtdTottenhamBrentfordAston VillaLiverpoolArsenalAFC Bournemouth
48ArsenalNewcastle Utdxxxxx
49Newcastle UtdMan CityBrentfordCrystal Palacexxx
50ArsenalTottenhamChelseaxxxx
51Newcastle UtdTottenhamBrentfordBrighton & HAxxx
52Tottenhamxxxxxx
53ArsenalMan CityAston VillaBrighton & HAxxx
54Newcastle UtdFulhamChelseaxxxx
55Newcastle UtdFulhamBrentfordBrighton & HAxxx
56Newcastle UtdTottenhamAston VillaMan CityLiverpoolAFC BournemouthChelsea
LMS #4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
H3:XFD3,1:2,A3:E3,4:1048576Expression=ROW(A1)=CurrentRowtextNO
Cells with Data Validation
CellAllowCriteria
I6:O56List=$H$139:$H$159



I am looking to auto populate the 'x' in any cell that has a strikethrough on the adjacent left cell? Obviously as the weeks move on I would need this to happen in any cell adjacent to a strikethrough no matter what column it was in?

1731334229474.png
 
Morning @Micron The button works now thank you. One thing though the 'X' go beyond my table, can this be limited to cells, is there a way of how far to tell this to go?

I am guessing it is going to Column Z as I have the small data table at the side of the main table?
1731916065218.png
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Well, asked but not answered as far as I can see:
- where the right most column would be for inserting X (or will it be dynamic?)
- where the left most column is - can't tell if Week1 is col A or something else
Will await your clarification.
 
Upvote 0
Well, asked but not answered as far as I can see:

Will await your clarification.
Hi, apologies, the table range is from column I to column V. The rows start at 6 but will vary in length dependant on number of people
 
Upvote 0
Try this version. I left modified parts in but double rem'd them out (2 apostrophes). You can remove these lines if you want.
Replace what you have between your Sub... End Sub lines with this:
VBA Code:
Dim Lrow As Long, Lcol As Long
Dim rng As Range, rng2 As Range, cel As Range
Dim row
'cols I to V, row start=6
On Error GoTo errHandler
With Application
    .EnableEvents = False
    .ScreenUpdating = False
End With

With ActiveSheet
'find last row with data 'removed search for right-most column, assigned 22 (col V )
    ''Lrow = .Cells.Find(what:="*", After:=Range("I5"), LookAt:=xlPart, LookIn:=xlFormulas, _
        SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).row
    ''Lcol = .Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
    Lrow = .Cells.Find(what:="*", After:=Range("I5"), LookAt:=xlPart, LookIn:=xlFormulas, _
        SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).row
    Lcol = 22
End With
'create range to loop over based on last row & column with data
''Set rng = Range(Cells(2, 1), Cells(Lrow, Lcol))
Set rng = Range(Cells(6, 9), Cells(Lrow, Lcol)) 'from (row 6, col I) to (last row, col V)
'loop over rows
For Each row In rng.rows
    'loop over cells in the current row
    For Each cel In row.Cells
        'if cel characters font setting is strikethrough:
        If Not cel Is Nothing And cel.Characters.Font.Strikethrough And cel <> "" Then
            'create range from next column to right to last column (based on what Lcol is)
            Set rng2 = Range(Cells(cel.row, cel.Column + 1), Cells(cel.row, Lcol))
            'remove potential strikethrough setting from rng2 lest a cell have previously been strikethrough
            rng2.Characters.Font.Strikethrough = False
            'set rng2 cells to equal X
            rng2 = "X"
        End If
    Next
Next

exitHere:
'clean up
Set rng = Nothing
Set rng2 = Nothing
With Application
    .EnableEvents = True
    .ScreenUpdating = True
End With
Exit Sub 'exit if no error

errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume exitHere

I hope you are trying this on a copy of your wb. If it still isn't right then you may have to follow up on uploading a copy to a file share. Google sheets are of no use for vba code.
 
Upvote 0
Yes I am trying this on a copy.

I actually uploaded my excel workbook to google drive so unsure how it has come to you...

I will reply again once I have updated the code
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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