I wonder if anybody can help, I have put some code together with a great deal of help from Fluff on this site.
I have now moved onto the next stage, which I have working but not exactly as I need.
I have the code copying and pasting to variable sheet name but I have two problems
1. Its copying and pasting formats & I need xlValues only
2. Its copying the filtered data OK but is also copying the next blank cell after the filtered data
Any help is appreciated
Here is what I have tried
I have now moved onto the next stage, which I have working but not exactly as I need.
I have the code copying and pasting to variable sheet name but I have two problems
1. Its copying and pasting formats & I need xlValues only
2. Its copying the filtered data OK but is also copying the next blank cell after the filtered data
Any help is appreciated
Code:
Sub Addholidays()
Dim WB As Workbook
Dim CurrentSheet As Worksheet
Set CurrentSheet = ActiveSheet
Dim Sh As Worksheet
Dim Locate As Range
Dim Nme As String
Dim Fnd As Range
Application.ScreenUpdating = False
Sheets("Planner").Select
Nme = ActiveCell.Value
Ans = MsgBox("Have you selected the correct employee name " & ActiveCell.Value, vbYesNo)
If Ans = vbNo Then Exit Sub
'On Error GoTo ErrorHandler
Sheets("Planner").Select
Nme = ActiveCell.Value
Sheets("Collated Data").Visible = True
Sheets("Collated Data").Select
With Sheets("Collated Data")
If .AutoFilterMode Then .AutoFilterMode = False
Set Fnd = .Range("D4:BP4").Find(Nme, , xlValues, xlWhole, , , False, , False)
.Range("D4:BP4").AutoFilter Fnd.Column - 3, "<>" ' this is filtering 3 rows down (Header Row) from row1
.AutoFilter.Range.Offset(1).Columns(Fnd.Column - 3).Copy Sheets(Nme).Range("D26")
.AutoFilter.Range.Offset(1).Columns(1).Copy Sheets(Nme).Range("C26")
.AutoFilterMode = False
Sheets("Collated Data").Visible = False
Sheets("Planner").Select
Application.ScreenUpdating = True
Exit Sub
ErrorHandler: MsgBox ("Sheet for this employee has not been created."), , "Check Sheet is named correctly"
End With
End Sub
Here is what I have tried
Code:
'.AutoFilter.Range.Offset(1).Columns(Fnd.Column - 3).Copy Sheets(Nme).Range.xlValues("D26")
'.AutoFilter.Range.Offset(1).Columns(1).Copy Sheets(Nme).Range.xlValues("C26")
'
'.AutoFilter.Range.Offset(1).Columns(Fnd.Column - 3).Copy Sheets(Nme).Range("D26").xlValues
'.AutoFilter.Range.Offset(1).Columns(1).Copy Sheets(Nme).Range("C26").xlValues
'
'.AutoFilter.Range.Offset(1).Columns(Fnd.Column - 3).Copy.xlValues Sheets(Nme).Range("D26")
'.AutoFilter.Range.Offset(1).Columns(1).Copy.xlValues Sheets(Nme).Range("C26")