EdgeJ
11-05-2009, 09:59 AM
Hi everyone, I'm really new to VBA so be patient with me here.
I've set the value of cell AD1 on a worksheet to 4, but it isn't picking this up, I'm wondering if this is to do with the fact that I have hidden the AD column, or due to the fact that there is an error in my code?
I'll show you what I have so far (I've highlighted what I think is the part you'll need to refer to):
Public current
Sub CVariable()
current = ActiveWorkbook.Worksheets("Sheet1").Range("AD1").Value
End Sub
Private Sub NextStu_Click()
MsgBox "The value of current is:" & current
End Sub
Private Sub BackToMenu_Click()
NewStudent.Hide
End Sub
Private Sub StudentSearch_Click()
AdvancedSearch.Show
End Sub
Private Sub Save_Click()
If ActiveSheet.Cells(current, 2) = "" Then
current = current
Else
current = (current + 1)
End If
ActiveSheet.Cells(current, 2).Value = FirstName.Text
ActiveSheet.Cells(current, 3).Value = LastName.Text
ActiveSheet.Cells(current, 4).Value = Gender.Text
ActiveSheet.Cells(current, 5).Value = DOBDay.Text
ActiveSheet.Cells(current, 6).Value = DOBMonth.Text
ActiveSheet.Cells(current, 7).Value = DOBYear.Text
ActiveSheet.Cells(current, 8).Value = Mod1.Text
ActiveSheet.Cells(current, 9).Value = Mod2.Text
ActiveSheet.Cells(current, 10).Value = Mod3.Text
ActiveSheet.Cells(current, 11).Value = Mod4.Text
ActiveSheet.Cells(current, 12).Value = Mod5.Text
ActiveSheet.Cells(current, 13).Value = Mod6.Text
End Sub
I've set the value of cell AD1 on a worksheet to 4, but it isn't picking this up, I'm wondering if this is to do with the fact that I have hidden the AD column, or due to the fact that there is an error in my code?
I'll show you what I have so far (I've highlighted what I think is the part you'll need to refer to):
Public current
Sub CVariable()
current = ActiveWorkbook.Worksheets("Sheet1").Range("AD1").Value
End Sub
Private Sub NextStu_Click()
MsgBox "The value of current is:" & current
End Sub
Private Sub BackToMenu_Click()
NewStudent.Hide
End Sub
Private Sub StudentSearch_Click()
AdvancedSearch.Show
End Sub
Private Sub Save_Click()
If ActiveSheet.Cells(current, 2) = "" Then
current = current
Else
current = (current + 1)
End If
ActiveSheet.Cells(current, 2).Value = FirstName.Text
ActiveSheet.Cells(current, 3).Value = LastName.Text
ActiveSheet.Cells(current, 4).Value = Gender.Text
ActiveSheet.Cells(current, 5).Value = DOBDay.Text
ActiveSheet.Cells(current, 6).Value = DOBMonth.Text
ActiveSheet.Cells(current, 7).Value = DOBYear.Text
ActiveSheet.Cells(current, 8).Value = Mod1.Text
ActiveSheet.Cells(current, 9).Value = Mod2.Text
ActiveSheet.Cells(current, 10).Value = Mod3.Text
ActiveSheet.Cells(current, 11).Value = Mod4.Text
ActiveSheet.Cells(current, 12).Value = Mod5.Text
ActiveSheet.Cells(current, 13).Value = Mod6.Text
End Sub