ShawnExcel
Member
I am trying to make a Macro that goes into another spreadsheet to delete a certain row of data.
In the user spreadsheet, the user enters the following info:
A1: Case ID
A2: Your name
A3: Date
The macro then goes into "Master Database" and finds the row that matches all 3 of the above criteria, makes the values blank, and then closes the file. Here is what I have so far:
Your help is greatly appreciated!
In the user spreadsheet, the user enters the following info:
A1: Case ID
A2: Your name
A3: Date
The macro then goes into "Master Database" and finds the row that matches all 3 of the above criteria, makes the values blank, and then closes the file. Here is what I have so far:
Code:
Sub DeleteCST()
Dim CaseNumberDelete As String
Dim DateDelete As Date
Dim IntranetIDDelete as String
Dim FindRowNumber As Long
'Set This Woorkbook as a saved variable
UserFormWorkbook = ActiveWorkbook.Name
'ActiveWindow.Visible = True
CaseNumberDelete = ThisWorkbook.Sheets("Whoops").Range("A1").Value
IntranetIDDelete = ThisWorkbook.Sheets("Whoops").Range("A2").Value
DateDelete = ThisWorkbook.Sheets("Whoops").Range("A3").Value
If CaseNumberDelete = "" Then
MsgBox ("You forgot to enter a case number!")
Exit Sub
Else
If MsgBox("ARE YOU SURE YOU WANT TO DELETE THIS CASE?", vbOKCancel, "Confirm") = vbCancel Then
Exit Sub
End If
'Find and Locate the Main Master Sheet
Workbooks.Open ("C:/...")
'Windows("Master Database 2016.csv").Visible = False
With WB.Sheets("Master Database 2016")
Set FindRow = .Range("A:A").Find(What:=CaseNumberDelete, LookIn:=xlValues)
FindRowNumber = FindRow.Row
End With
'Don't display alerts when closing the master
Application.DisplayAlerts = False
ActiveWorkbook.Save
Workbooks("Master Database 2016.csv").Close SaveChanges:=True
MsgBox ("You have successfully deleted your case!")
End Sub
Your help is greatly appreciated!