This Code in the attached appears to do as you require. I've assumed NO to this
Option Explicit
Sub Clear_Data()
Dim ws1 As Worksheet
Dim LR1 As Long
Dim LC1 As Long
Set ws1 = Sheets("Decision support tool")
With ws1
LR1 = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
LC1 = .Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
If LR1 = 35 Then LR1 = 36
.Range(.Cells(36, "B"), .Cells(LR1, LC1)).ClearContents
End With
End Sub
Sub Run_Me()
Dim ws As Worksheet
Dim ws1 As Worksheet
Dim rng As Range
Dim LR As Long
Dim LC As Long
Dim LR1 As Long
Dim LC1 As Long
Dim x As Long
Set ws = Sheets("Emp Database")
Set ws1 = Sheets("Decision support tool")
With ws1
LR1 = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
LC1 = .Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
If LR1 = 35 Then LR1 = 36
.Range(.Cells(36, "B"), .Cells(LR1, LC1)).ClearContents
End With
With ws
LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
LC = .Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
.Range(.Cells(35, "B"), .Cells(LR, LC)).AutoFilter field:=4, Criteria1:=ws1.Range("F23").Value
.Range(.Cells(35, "B"), .Cells(LR, LC)).AutoFilter field:=5, Criteria1:=ws1.Range("F24").Value
Set rng = .AutoFilter.Range
x = rng.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1
If x >= 1 Then
.Range(.Cells(36, "B"), .Cells(LR, LC)).SpecialCells(xlCellTypeVisible).Copy
ws1.Range("B36").PasteSpecial
Application.CutCopyMode = False
Else
MsgBox "No Records Found"
End If
.AutoFilterMode = False
End With
End Sub
Sub DoTheWork()
Dim myBtn As Button
Dim myGroup As String
Dim ws As Worksheet
Dim LC As Long
Dim LR As Long
Set myBtn = Sheets("Decision support tool").Buttons(Application.Caller)
myGroup = Right(myBtn.Caption, 1)
Set ws = Sheets("Decision support tool")
Application.ScreenUpdating = False
With ws
LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
LC = .Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
If Not .AutoFilterMode Then
.Range(.Cells(35, "B"), .Cells(LR, LC)).AutoFilter
End If
.Range(.Cells(35, "B"), .Cells(LR, LC)).AutoFilter field:=8, Criteria1:=myGroup
End With
Application.ScreenUpdating = True
End Sub
Sub Show_All()
On Error Resume Next
Sheets("Decision support tool").ShowAllData
On Error GoTo 0
End Sub
Sub Update()
Dim ws As Worksheet
Dim ws1 As Worksheet
Dim rng As Range
Dim rng1 As Range
Dim cel As Range
Dim c As Range
Dim LR As Long
Dim LR1 As Long
Dim LC1 As Long
Set ws = Sheets("Emp Database")
Set ws1 = Sheets("Decision support tool")
With ws1
LR1 = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
LC1 = .Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
Set rng1 = ws1.Range(ws1.Cells(36, "B"), ws1.Cells(LR1, "B")).SpecialCells(xlCellTypeVisible)
End With
With ws
LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
Set rng = ws.Range(ws.Cells(36, "B"), ws.Cells(LR, "B"))
End With
Application.ScreenUpdating = False
For Each cel In rng1
Set c = rng.Find(cel.Value, , xlValues, xlWhole, xlByRows, xlNext, False)
ws1.Range(ws1.Cells(cel.Row, "B"), ws1.Cells(cel.Row, LC1)).Copy
ws.Cells(c.Row, "B").PasteSpecial (xlPasteValues)
Next cel
Application.ScreenUpdating = True
End Sub
Display More