LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Calling Sub difficulty

Hello XLers

I'm quite new to Excel, and need some newbie help. Dave Peterson was very
helpful when I posed this a week ago, giving the code below. I arrived back
in town today, and I just can't get the second procedure to work.

Basically, my worksheet contains form buttons (actually 5). When clicked,
they will run Giselle that, in turn, calls Common.

MyQuestion: I keep getting error msgs at the Set lines. (Compile Error:
variable not defined. If I provide Dim statements, I still get Compile
Error: Object required.) I'm not even sure why I would need these lines???

Could someone show me how to get the 2nd procedure to work. (perhaps you
could even replace the " 'xxxxxxx common code goes here" line with a simple
task such as coloring the cells of R1 red and printing the text in R2 in
cell A1)

Dave's excellent code!

Option Explicit
Sub Giselle()
Dim R1 as String
Dim R2 as string

R1 = ""
R2 = ""

Select Case lcase(Application.Caller)
Case "button 1"
R1 = "D5:J25"
R2 = "Ford"
Case "button 2"
R1 = "J5:K25"
R2 = "Chrysler"
End Select

If R1 = "" then
beep
msgbox "Design error. See Giselle!
exit sub
End if

call Common(R1,R2)
End Sub


Sub Common(R1 as String, R2 as String)

with worksheets("Sheet99") 'or Activesheet ????
Set RangeToWorkOn = .Range(R1)
Set StringToWorkOn = .Range(R2)
end with

'xxxxxxxx common code goes in here

End Sub



THANKYOU very much for any assistance
Giselle



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function Difficulty Johnnie[_2_] Excel Discussion (Misc queries) 5 October 20th 08 09:54 PM
Formula difficulty Pyrite Excel Discussion (Misc queries) 5 October 8th 08 08:13 PM
VLOOKUP Difficulty Serge Excel Discussion (Misc queries) 5 June 21st 06 02:50 AM
Difficulty with MOD operator when using Mod 1 Terry Holmes Excel Programming 5 April 27th 05 09:52 PM
difficulty with logical - if - and billabong Excel Programming 5 September 20th 03 10:55 PM


All times are GMT +1. The time now is 07:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"