call a macro with arguments in a Command Button

G

Guest

1.) How do you call a macro with Cell value arguments in a Command Button on
Sheet1
which passes Cell A1 value, not cell A1 reference.
'Target' argument must pass A1 value

Problem is 'Target' passes back the cell reference not the value in the Cell.

Example
Public Sub Cmd_Services_Click(ByVal Target As CommandButton)
' A1 value is Supplies
'run code in Sheet1
ABC('Range("$A$1").Value) ????
End Sub

2.) In the properties window for command button, Name = Cmd_Services
Should it be Name - Cmd_Services(A1) ?
Cmd_Services(Sheet1!A1) ?
 
G

Guest

Hi

Try the below example

Public Sub tESTER2(MyCell As Range)
Dim rsp
rsp = MsgBox(MyCell.Value, vbOKOnly)
End Sub

In the immediate window type your range in the call to the Sub e.g.

tester2(Worksheets("Sheet4").cells(1,1))
 

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