Hey guys hope i can get some help this issue i am having. first of i am a bit of a novice with excel so its no wonder i cant locate the error here is the scenario.
I wrote a macro that would automatically update data from one sheet into another work sheet when I entered information and clicked update. When I enter information and click update the info is entered into the first row under the header no problem, but it does not automatically go to the next row, so when i try to enter the next series of info i get the run-time error. please see below a copy of the code
Private Sub CommandButton1_Click()
Dim StudentFirstName As String, StudentLastName As String, StudentGender As String, StudentGrade As String, StudentIdAssigned As String, DateAssigned As String
Worksheets("Sheet1").Select
StudentFirstName = Range("C5")
StudentLastName = Range("C6")
StudentGender = Range("C7")
StudentGrade = Range("C8")
StudentIdAssigned = Range("C9")
DateAssigned = Range("C10")
Worksheets("Sheet2").Select
Worksheets("Sheet2").Range("A9").Select
If Worksheets("Sheet2").Range("A9").Offset(1, 0) <> "" Then
Worksheets("Sheet2").Range("A9").End(x1Down).Select
End If
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = StudentFirstName
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = StudentLastName
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = StudentGender
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = StudentGrade
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = StudentIdAssigned
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = DateAssigned
Worksheets("Sheet1").Select
Worksheets("Sheet1").Range("C5").Select
Worksheets("Sheet1").Range("C5:C10").ClearContents
Debugging always identifies this line of code as the culprit Worksheets("Sheet2").Range("A9").End(x1Down).Select
but i cant figure out why.
any help in this regard would be much appreciated.
Bookmarks