I have code which checks when an entry is trying to be made and the Number in column A [Quote #] of a Table [QuotationList} is already present
Currently, if this true, it simply exits
What I want to do is to ask the User if they want to overwrite the current row with the new data and if they say Yes then overwrite the row otherwise then exit. but I am struggling
This is my current code:
Any suggestions gratefully received
Thanks for looking
Currently, if this true, it simply exits
What I want to do is to ask the User if they want to overwrite the current row with the new data and if they say Yes then overwrite the row otherwise then exit. but I am struggling
This is my current code:
Code:
Sub SaveQuotation()
Dim xRng As Range
Dim xrng2 As Range
Dim strQuote As String
Dim TblRng As Range
Dim ws As Worksheet
Dim tbl As ListObject
Dim MyRange As Range, FindQuote As Range
Dim LastRow As Long
Set ws = ActiveSheet
Worksheets("Quotation List").Activate
'THIS IS THE CELL WITH THE QUOTE # IN
strQuote = Sheets("Quotation").Range("G7")
With ThisWorkbook.Worksheets("Quotation List")
'THIS IS THE COLUMN WHERE THE QUOTE # WILL BE PLACED
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
If LastRow = 4 And .Range("A3") = "" Then LastRow = 3
Set FindQuote = .Range("A3:A" & LastRow).Find(strQuote, , xlValues, xlWhole)
'THIS IS WHAT HAPPENS NOW
If Not FindQuote Is Nothing Then
MsgBox "Quotation Number already exists"
Exit Sub
End If
.Cells(LastRow, .Range("QuotationList[Quote '#]").Column) = Sheets("Quotation").Range("G7")
.Cells(LastRow, .Range("QuotationList[Date]").Column) = Sheets("Quotation").Range("G8")
.Cells(LastRow, .Range("QuotationList[Customer]").Column) = Sheets("Quotation").Range("A3")
.Cells(LastRow, .Range("QuotationList[Total]").Column) = Sheets("Quotation").Range("G21")
Set xRng = .Cells(LastRow, .Range("QuotationList[pdf Copy Location]").Column)
Set xrng2 = .Cells(LastRow, .Range("QuotationList[xlsx Copy Location]").Column)
End With
Worksheets("Quotation").Activate
Call SaveQuotationAsPDF(xRng)
Call CopyWorksheet(xrng2)
End Sub
Any suggestions gratefully received
Thanks for looking