TopLearner
Board Regular
- Joined
- Feb 25, 2022
- Messages
- 57
- Office Version
- 365
- Platform
- Windows
Good afternoon everybody,
I hope you are well.
I have a sheet (“Sheet1”) with data on it.
I want to write a code that does the following actions:
I know how to do the 1 and 2 steps but I am stuck with the 3rd and 4th.
Can you kindly help?
My code is
Thanks
Sanchez
I hope you are well.
I have a sheet (“Sheet1”) with data on it.
I want to write a code that does the following actions:
- Delete the first row
- Delete the columns that have the following headers: "Employee Number", "Pay Class Name", "Pay Type Name", "Job Name", "Pay Category Name", "Employee Punch Employee Comment", "Employee Punch Manager Comment", "Employee Pay Adjust Employee Comment", "Employee Pay Adjust Manager Comment"
- Find and select the column whose header is “Site”
- Delete those rows where in column “Site” cells say (Australia)
I know how to do the 1 and 2 steps but I am stuck with the 3rd and 4th.
Can you kindly help?
My code is
VBA Code:
Sub cleanupsheet()
Dim ws As Worksheet
Dim i As Long
Rows(1).EntireRow.Delete
Set ws = Sheet1
With ws
For i = 16 To 1 Step -1
Select Case .Cells(1, i).Value
Case "Employee Number", "Pay Class Name", "Pay Type Name", "Job Name", "Pay Category Name", "Employee Punch Employee Comment", "Employee Punch Manager Comment", "Employee Pay Adjust Employee Comment", "Employee Pay Adjust Manager Comment"
.Columns(i).Delete
End Select
Next i
End With
Dim Location As Range
Set Location = Rows(1).Find("Site")
Thanks
Sanchez