Set variable equal to a cell value & more

A

Al

I have a three part question.
First, I want to be able to assign a value in a cell, on
only one of three worksheets, to a variable.
Second, I want to be able to compare that value using a
CASE statement.
Finally, I want to be able to associate this macro to a
command button that will run it.
Thanks in advance,
Al
 
T

Tom Ogilvy

Private Sub CommandButton1_Click
vVal = Worksheets("Sheet1").Range("B9").Value

Select Case vVal
Case 1

Case 2

Case Else
End Select
End Sub


Not sure of the significance of 1 of 3 worksheets.

Place a commandbutton on your sheet. Double click on it while in design
mode and you should get the declaration

Private Sub CommandButton1_Click

End Sub

You can add code in this procedure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top