djsouthcott
New Member
- Joined
- Jun 30, 2014
- Messages
- 9
Hi I have a userform which applies a set data group to a work sheet as an invoice then saves it but this code keeps asking me to save changes when all i want it to do is save using a new unique invoice number, please be aware i'm not great at VB just getting to grips with it after years of only scratching the surface.
Private Sub CommandButton1_Click()
Range("B8") = TextBox1.Text
Range("I10") = TextBox2.Text
Range("I11") = TextBox3.Text
Range("I13") = TextBox4.Text
Range("I16") = TextBox5.Text
Range("B21") = TextBox6.Text
Range("C21") = TextBox7.Text
Range("H21") = TextBox8.Text
Dim reply As String
reply = "yes"
Dim row As Long
row = 22
Dim path As String
path = "E:\invoices\"
Do While reply = "yes" Or reply = "y" Or reply = "Y" Or reply = "Yes"
reply = InputBox("do you wish to add another item to this invoice? Yes / No.", "Add More Items?")
If reply = "no" Or reply = "n" Or reply = "N" Or reply = "No" Then
Application.DisplayAlerts = False
Dim NewFN As Variant
ActiveSheet.Copy
ThisWorkbook.SaveAs Filename:=path & Range("B8").Text & "_" & Range("I7"), FileFormat:=51
Application.DisplayAlerts = True
ActiveWorkbook.Close
Else
qty = InputBox("please enter the qauntity of the next item.", "Enter Quantity")
Cells(row, 2) = qty
Description = InputBox("please enter a description for your next item.", "Description")
Cells(row, 3) = Description
unitprice = InputBox("please enter unit price for the next item.", "Unit Price")
Cells(row, 8) = unitprice
End If
row = row + 1
Loop
Range("I7").Value = Range("I7").Value + 1
End Sub
Private Sub CommandButton1_Click()
Range("B8") = TextBox1.Text
Range("I10") = TextBox2.Text
Range("I11") = TextBox3.Text
Range("I13") = TextBox4.Text
Range("I16") = TextBox5.Text
Range("B21") = TextBox6.Text
Range("C21") = TextBox7.Text
Range("H21") = TextBox8.Text
Dim reply As String
reply = "yes"
Dim row As Long
row = 22
Dim path As String
path = "E:\invoices\"
Do While reply = "yes" Or reply = "y" Or reply = "Y" Or reply = "Yes"
reply = InputBox("do you wish to add another item to this invoice? Yes / No.", "Add More Items?")
If reply = "no" Or reply = "n" Or reply = "N" Or reply = "No" Then
Application.DisplayAlerts = False
Dim NewFN As Variant
ActiveSheet.Copy
ThisWorkbook.SaveAs Filename:=path & Range("B8").Text & "_" & Range("I7"), FileFormat:=51
Application.DisplayAlerts = True
ActiveWorkbook.Close
Else
qty = InputBox("please enter the qauntity of the next item.", "Enter Quantity")
Cells(row, 2) = qty
Description = InputBox("please enter a description for your next item.", "Description")
Cells(row, 3) = Description
unitprice = InputBox("please enter unit price for the next item.", "Unit Price")
Cells(row, 8) = unitprice
End If
row = row + 1
Loop
Range("I7").Value = Range("I7").Value + 1
End Sub
Last edited: