View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kevin_Waite Kevin_Waite is offline
external usenet poster
 
Posts: 2
Default passing a parameter from a button invoked VBA macro?

Hello....
I have found several examples on line for setting the .OnAction member
with something akin to '!FooBar ABC 555"

I can not get that to work -- tried many many permutations of " and '
and spaces and comas -- no go....

I am using MS VB 6.0 and Excel 2000.

I'd like to get rid of the four stem macros that are assigned to 4
buttons -- and just call srt_otot with the correct parm via the button
setup etc. . . . thanks in advance. . . . sincerely, Kevin Waite

Public Sub srt_otot_1()
Call srt_otot(1)
End Sub

Public Sub srt_otot_2()
Call srt_otot(2)
End Sub

Public Sub srt_otot_3()
Call srt_otot(3)
End Sub

Public Sub srt_otot_4()
Call srt_otot(4)
End Sub

Sub srt_otot(x As Integer)

Application.ScreenUpdating = False

cur_loc = ActiveCell.Address

If x < 1 And x < 2 And x < 3 And x < 4 Then
y = 1 / 0
End If

Range("B3").Select
top_rw = ActiveCell.Row

Range("B65536").End(xlUp).Select
bot_rw = ActiveCell.Row

If (bot_rw - top_rw) 250 Then y = 1 / 0

Rows(top_rw & ":" & bot_rw).Select

If srtot_flg(x) < 1 And srtot_flg(x) < 2 Then
srtot_flg(x) = 1
End If

srt_dir = xlDescending
If srtot_flg(x) = 1 Then
srt_dir = xlAscending
srtot_flg(x) = 2
Else
srtot_flg(x) = 1
End If

srt_col = Switch(x = 1, "B3", x = 2, "C3", x = 3, "H3", x = 4,
"Q3")

Selection.Sort Key1:=Range(srt_col), Order1:=srt_dir,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Range(cur_loc).Select

Application.ScreenUpdating = True

End Sub