bourneme
10-29-2008, 08:49 AM
Hi there, i'm fairly new to vb and would very much appreciate some help.
The situation:
I have a number of buttons on several sheets within a Workbook. Each Button should link to a value, that can then be put into a module for a process to occur based on this value.
Sheet1
CommandButton1 stores XVal = 1
CommandButton2 stores XVal = 2
Sheet2
CommandButton1 - XVal = 1
etc etc.
I want this Xval to be a part of a calculation within a module setstatus
----------
Private Sub CommandButton158_Click()
Xval = 158
Call SetStatus
End Sub
Private Sub CommandButton143_Click()
Xval = 143
Call SetStatus
End Sub
Sub SetStatus()
ActiveSheet.Unprotect ("****")
status = Cells(Xval, 6)
If status = "" Then
status = "Not Loading"
End If
If status = "Not Loading" Then
Call NotLoadingToLoadingChange
ElseIf status = "Loading" Then
Call LoadingToLoadComplete
ElseIf status = "Load Completed" Then
Call LoadComplete
End If
ActiveSheet.Protect ("****")
End Sub
This works fine, but I would prefer to have the SetStatus Sub in a module. As it would be referred to from several sheets.
Any Help much appreciated
Thanks,
The situation:
I have a number of buttons on several sheets within a Workbook. Each Button should link to a value, that can then be put into a module for a process to occur based on this value.
Sheet1
CommandButton1 stores XVal = 1
CommandButton2 stores XVal = 2
Sheet2
CommandButton1 - XVal = 1
etc etc.
I want this Xval to be a part of a calculation within a module setstatus
----------
Private Sub CommandButton158_Click()
Xval = 158
Call SetStatus
End Sub
Private Sub CommandButton143_Click()
Xval = 143
Call SetStatus
End Sub
Sub SetStatus()
ActiveSheet.Unprotect ("****")
status = Cells(Xval, 6)
If status = "" Then
status = "Not Loading"
End If
If status = "Not Loading" Then
Call NotLoadingToLoadingChange
ElseIf status = "Loading" Then
Call LoadingToLoadComplete
ElseIf status = "Load Completed" Then
Call LoadComplete
End If
ActiveSheet.Protect ("****")
End Sub
This works fine, but I would prefer to have the SetStatus Sub in a module. As it would be referred to from several sheets.
Any Help much appreciated
Thanks,