Hello,
I am new to Excel VB. I am trying to make a Excel workbook whereby through an InputBox a user can enter a new client and it asks for their details however it keeps entering new information on the same row as the last one, I dont know how to stop that and make it enter on a new row underneath the old one here is the code I have so far:
ub Button1_Click()
Dim emptyRow As Long
Dim i As Integer
Range("a1").Select
Range(Selection, Selection.End(xlDown)).Select
i = Selection.Rows.Count
'Make Sheet2 Active
Sheets(2).Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Dim ClientStat As String
Dim StrCustRef As String
Dim StrCompName As String
Dim ContactName As String
Dim Telephone As Single
Dim email As String
Dim ContDate As Date
Dim DateSentOffice As Date
Dim ClientReplyDate As Date
Dim ListSentDate As Date
Dim orders As String
Dim linkOrders As String
If Sheets("Sheet2").Range("K8") = "Y" Then
Sheets("Sheet2").Range("L8") = "Click for Orders"
End If
With Range("A:K")
ClientStat = "ES"
StrCustRef = InputBox("Please enter Customer Reference")
StrCompName = InputBox("Please Enter Company Name")
ContactName = InputBox("Please enter the name of the person you were in contact with")
Telephone = InputBox("Please enter client telephone Number")
email = InputBox("Please enter client email Adress")
ListSentDate = InputBox("Please Enter the Date the List and/or presentation were sent to the client")
ContDate = InputBox("Please enter the date when the client replyied to the presentation")
DateSentOffice = InputBox("Please enter the date the client request was sent to the office")
ClientReplyDate = InputBox("Please enter the date the client replied")
orders = InputBox("Orders Y/N")
Sheets("Sheet2").Range("A8") = ClientStat
Sheets("Sheet2").Range("B8") = StrCustRef
Sheets("Sheet2").Range("C8") = StrCompName
Sheets("Sheet2").Range("D8") = ContactName
Sheets("Sheet2").Range("E8") = Telephone
Sheets("Sheet2").Range("F8") = email
Sheets("Sheet2").Range("G8") = ContDate
Sheets("Sheet2").Range("H8") = DateSentOffice
Sheets("Sheet2").Range("I8") = ClientReplyDate
Sheets("Sheet2").Range("J8") = ListSentDate
Sheets("Sheet2").Range("K8") = orders
Dim last_row As Long
last_row = Range("A65536").End(xlUp).Row
Range("A10:K10").Copy
ActiveSheet.Paste Destination:=Range("A" & last_row + 1)
Range("A10:K10").ClearContents
Application.CutCopyMode = False
End With
End Sub
What I really want to do is for new client details to go on a new row, and to keep the old now in there. I am stuck so I would really appreciate help. Thanks
I am new to Excel VB. I am trying to make a Excel workbook whereby through an InputBox a user can enter a new client and it asks for their details however it keeps entering new information on the same row as the last one, I dont know how to stop that and make it enter on a new row underneath the old one here is the code I have so far:
ub Button1_Click()
Dim emptyRow As Long
Dim i As Integer
Range("a1").Select
Range(Selection, Selection.End(xlDown)).Select
i = Selection.Rows.Count
'Make Sheet2 Active
Sheets(2).Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Dim ClientStat As String
Dim StrCustRef As String
Dim StrCompName As String
Dim ContactName As String
Dim Telephone As Single
Dim email As String
Dim ContDate As Date
Dim DateSentOffice As Date
Dim ClientReplyDate As Date
Dim ListSentDate As Date
Dim orders As String
Dim linkOrders As String
If Sheets("Sheet2").Range("K8") = "Y" Then
Sheets("Sheet2").Range("L8") = "Click for Orders"
End If
With Range("A:K")
ClientStat = "ES"
StrCustRef = InputBox("Please enter Customer Reference")
StrCompName = InputBox("Please Enter Company Name")
ContactName = InputBox("Please enter the name of the person you were in contact with")
Telephone = InputBox("Please enter client telephone Number")
email = InputBox("Please enter client email Adress")
ListSentDate = InputBox("Please Enter the Date the List and/or presentation were sent to the client")
ContDate = InputBox("Please enter the date when the client replyied to the presentation")
DateSentOffice = InputBox("Please enter the date the client request was sent to the office")
ClientReplyDate = InputBox("Please enter the date the client replied")
orders = InputBox("Orders Y/N")
Sheets("Sheet2").Range("A8") = ClientStat
Sheets("Sheet2").Range("B8") = StrCustRef
Sheets("Sheet2").Range("C8") = StrCompName
Sheets("Sheet2").Range("D8") = ContactName
Sheets("Sheet2").Range("E8") = Telephone
Sheets("Sheet2").Range("F8") = email
Sheets("Sheet2").Range("G8") = ContDate
Sheets("Sheet2").Range("H8") = DateSentOffice
Sheets("Sheet2").Range("I8") = ClientReplyDate
Sheets("Sheet2").Range("J8") = ListSentDate
Sheets("Sheet2").Range("K8") = orders
Dim last_row As Long
last_row = Range("A65536").End(xlUp).Row
Range("A10:K10").Copy
ActiveSheet.Paste Destination:=Range("A" & last_row + 1)
Range("A10:K10").ClearContents
Application.CutCopyMode = False
End With
End Sub
What I really want to do is for new client details to go on a new row, and to keep the old now in there. I am stuck so I would really appreciate help. Thanks