Auto fill , pending data entered

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
667
Office Version
  1. 365
Platform
  1. Windows
Hi,

HMRC RTO Survey Sheet V2_Preston.xlsm
ABCDEFGHIJKLM
3
4Required
5RmFloorDeskDockUSB3K/BMouseMonitorHDMI/DVIDVI/DVINote / CommentsDate
6100010N K1111Part Kit07/07/2021
7100010501111Part Kit07/07/2021
8100010511111Part Kit07/07/2021
91000104911Part Kit07/07/2021
101000108111Part Kit07/07/2021
1110001017111Part Kit07/07/2021
1210001054111Part Kit07/07/2021
13Main Office1025No Kit07/07/2021
14Main Office10N K1111Part Kit07/07/2021
15Main Office10411111Part Kit07/07/2021
16Main Office104011111Part Kit07/07/2021
17Main Office10391111Part Kit07/07/2021
18Main Office103711111Part Kit07/07/2021
19Main Office10361111Part Kit07/07/2021
20Main Office1035111111Part Kit07/07/2021
21Main Office10341111Part Kit07/07/2021
22Main Office10331111Part Kit07/07/2021
23Main Office10321111Part Kit07/07/2021
24Main Office103011111Part Kit07/07/2021
25Main Office102911111Part Kit07/07/2021
26Main Office1028111111Part Kit07/07/2021
27P1110N K1111Part Kit07/07/2021
Site Survey
Cell Formulas
RangeFormula
A15:A26,B15:B27A15=IF(A14>0,A14,"")
Cells with Data Validation
CellAllowCriteria
K6:K27List=DropDown!$A$2:$A$5


Using the spreadsheet as shown above, this is the code behind:-


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)


Application.ScreenUpdating = False
    Dim rng As Range
      
    For Each rng In Range("k2:k1500")
        Select Case rng.Value
            Case "Part Kit"
                With Range("A" & rng.Row).Resize(1, 12)
                    .Interior.ColorIndex = 7
                    .Font.Bold = True
                End With
                
            Case "Full Kit"
                With Range("A" & rng.Row).Resize(1, 12)
                    .Interior.ColorIndex = 4
                    .Font.Bold = True
                End With
            Case "No Kit"
                With Range("A" & rng.Row).Resize(1, 12)
                    .Interior.ColorIndex = 6
                    .Font.Bold = True
                End With
            Case "Device Not Received"
                With Range("A" & rng.Row).Resize(1, 12)
                    .Interior.ColorIndex = 28
                    .Font.Bold = True
                End With
            Case "Emailed Requested For SCCM Check"
                With Range("A" & rng.Row).Resize(1, 12)
                    .Interior.ColorIndex = 38
                    .Font.Bold = True
                End With
            Case "Desktop UAD - On Hold ATM"
                With Range("A" & rng.Row).Resize(1, 12)
                    .Interior.ColorIndex = 44
                    .Font.Bold = True
                End With
            Case "Device With Build Engineer"
                With Range("A" & rng.Row).Resize(1, 12)
                    .Interior.ColorIndex = 40
                    .Font.Bold = False
                End With
            Case ""
                With Range("A" & rng.Row).Resize(1, 12)
                    .Interior.ColorIndex = xlNone
                    .Font.Bold = False
                End With
        End Select
    Next rng
    Application.ScreenUpdating = True

Const BINARY_RANGE      As String = "d6:J999"
    Const COMMENTS_RANGE    As String = "K6:K999"

    Const PLACEHOLDER       As String = "$@#@$"
    Const MESSAGE           As String = "Cell $@#@$ Only 1 Is Allowed!"
    
    Dim Act As Boolean
    Dim c   As Range
    
    Application.EnableEvents = False
    For Each c In Target
        Act = False
        If Not Application.Intersect(c, Range(BINARY_RANGE)) Is Nothing Then
            If IsError(c.Value) Then
                Act = True
            ElseIf c.Value = vbNullString Then
                ' do nothing
            Else
                If c.Value <> 0 And c.Value <> 1 Then
                    Act = True
                End If
            End If
            If Act Then
                c.Value = vbNullString
                MsgBox Replace(MESSAGE, PLACEHOLDER, c.Address)
            End If
        End If
    Next c
    For Each c In Target
        If Not Application.Intersect(c, Range(COMMENTS_RANGE)) Is Nothing Then
            If IsError(c.Value) Then
                c.Offset(0, 1).Value = vbNullString
            Else
                If Len(c.Value) = 0 Then
                    c.Offset(0, 1).Value = vbNullString
                Else
                    c.Offset(0, 1).Value = Date
                End If
            End If
        End If
    Next c
    Application.EnableEvents = True



If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub



    On Error Resume Next

    If Not Intersect(Target, Range("jb2:jb100")) Is Nothing Then

        Application.EnableEvents = False

        Target = UCase(Target)

        Application.EnableEvents = True

    End If
      

    On Error GoTo 0


If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub


    On Error Resume Next

    If Not Intersect(Target, Range("b1:b1")) Is Nothing Then

        Application.EnableEvents = False

        Target = StrConv(Target, vbProperCase)

        Application.EnableEvents = True

    End If

    On Error GoTo 0
If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub


    On Error Resume Next

    If Not Intersect(Target, Range("k")) Is Nothing Then

        Application.EnableEvents = False

        Target = StrConv(Target, vbProperCase)

        Application.EnableEvents = True

    End If

    On Error GoTo 0
    
    
    
 If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub



    On Error Resume Next

    If Not Intersect(Target, Range("d1:d100")) Is Nothing Then

        Application.EnableEvents = False

        Target = LCase(Target)

        Application.EnableEvents = True

    End If

    On Error GoTo 0
    
    
         
    
End Sub




It works great, but would prefer rather than picking from the drop down list (Part Kit, col k, which is in a 'drop down' list) it would do this upon entering the retrospective number 1. This spreadsheet is used as a inventory. Which has 500+ entries to be done for each office, on every floor througtout the complete estate. So anything that can speed up the process is a bonus.


My sincere thanks goes out to the person(s) who likes a challenge & can sort this for me / team.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,214,806
Messages
6,121,667
Members
449,045
Latest member
Marcus05

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