Help with coding for saving new invoice with new invoice number..... :(

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
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,224,977
Messages
6,182,117
Members
453,090
Latest member
boonga

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top