Hi,
I am struggling to get my project to work as I want. I am just learning.
I am creating an invoice system where the user enters the data via a userform and struggling to find a method to go to the next row.
Once the user has entered the first line of data and clicks CommandButton Add, the userform is cleared and the user needs to enter the second line of data in the same textboxes.
The problem that I have is the data has to be entered into a specific range. i.e. first row is D13 to F13, then once added the second row
needs to be copied to D14 to F14 and so on.
I can get it to find the last row and enter the data using the following but not in the specific cells I require
Sheets("Sheet1").Activate
Lastrow = Sheets("Sheet1").Range("D" & Rows.count).End(xlUp).Row
Cells(Lastrow + 1, "D").Value = TxtQty.Value
Cells(Lastrow + 1, "E").Value = TxtDes.Value
Cells(Lastrow + 1, "F").Value = TxtRate.Value
If TxtRate.Value = "" Then
Range("F13").Value = TxtMRate.Value
End If
TxtQty.Value = ""
TxtDes.Value = ""
TxtRate.Value = ""
TxtMRate.Value = ""
I have also tried the following where it will copy the data to the correct cells but can't work out how to move to the next row once the
Button is clicked and data is cleared.
Range("D13").Value = TxtQty.Value
Range("E13").Value = TxtDes.Value
Range("F13").Value = TxtRate.Value
If TxtRate.Value = "" Then
Range("F13").Value = TxtMRate.Value
End If
TxtQty.Value = ""
TxtDes.Value = ""
TxtRate.Value = ""
TxtMRate.Value = ""
Hope someone can assist, This is the last piece of code required to complete the project.
Regards and Thanks in Advance.
I am struggling to get my project to work as I want. I am just learning.
I am creating an invoice system where the user enters the data via a userform and struggling to find a method to go to the next row.
Once the user has entered the first line of data and clicks CommandButton Add, the userform is cleared and the user needs to enter the second line of data in the same textboxes.
The problem that I have is the data has to be entered into a specific range. i.e. first row is D13 to F13, then once added the second row
needs to be copied to D14 to F14 and so on.
I can get it to find the last row and enter the data using the following but not in the specific cells I require
Sheets("Sheet1").Activate
Lastrow = Sheets("Sheet1").Range("D" & Rows.count).End(xlUp).Row
Cells(Lastrow + 1, "D").Value = TxtQty.Value
Cells(Lastrow + 1, "E").Value = TxtDes.Value
Cells(Lastrow + 1, "F").Value = TxtRate.Value
If TxtRate.Value = "" Then
Range("F13").Value = TxtMRate.Value
End If
TxtQty.Value = ""
TxtDes.Value = ""
TxtRate.Value = ""
TxtMRate.Value = ""
I have also tried the following where it will copy the data to the correct cells but can't work out how to move to the next row once the
Button is clicked and data is cleared.
Range("D13").Value = TxtQty.Value
Range("E13").Value = TxtDes.Value
Range("F13").Value = TxtRate.Value
If TxtRate.Value = "" Then
Range("F13").Value = TxtMRate.Value
End If
TxtQty.Value = ""
TxtDes.Value = ""
TxtRate.Value = ""
TxtMRate.Value = ""
Hope someone can assist, This is the last piece of code required to complete the project.
Regards and Thanks in Advance.
Last edited: