LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default vba code problem

Remove the parentheses that are around the argument list in the call to the subs.

Sub alterSheet()
Hide_Cells Range("C22:L28")
End Sub

Sub alterSheet2()
Reveal_Cells 3, Range("C21:L28")
End Sub

This is a potentially confusing topic, but you only use parentheses around an argument list when the procedure returns a value that
is being captured (or you use Call).

--

John Green - Excel MVP
Sydney
Australia


"Steve" wrote in message ...
I have written the code below to switch on and off a
coloured input range. The code worked fine in its raw
form but as I try to make it more concise I have
encountered problems, such as VBA suggesting there should
be an '=' after my call to Reveal_Cells

Have I misunderstood the nature of subroutines??

Steve


Sub alterSheet()
Hide_Cells (Range("C22:L28"))
End Sub

Sub alterSheet2()
Reveal_Cells (3,Range("C21:L28")) 'wants = here??
End Sub


Private Sub Hide_Cells(Rng As Range)
Dim c As Range

For Each c In Rng.Cells
c.Interior.ColorIndex = 2
c.Font.ColorIndex = 2
c.Value = 0
Next c

End Sub

Private Sub Reveal_Cells(Default_Value As Variant, Rng As
Range)
Dim c As Range

For Each c In Rng.Cells
c.Interior.ColorIndex = 19
c.Font.ColorIndex = 5
c.Value = Default_Value
Next c

End Sub



 
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
Problem with code kk Excel Discussion (Misc queries) 0 March 15th 08 03:01 PM
VB Code Problem Stan Excel Discussion (Misc queries) 6 April 25th 07 01:48 AM
XLS to CSV Code Problem carl Excel Worksheet Functions 0 March 28th 07 01:21 AM
Code problem Rick[_11_] Excel Programming 1 August 8th 03 04:25 AM
Code Problem ! Mike R Excel Programming 5 August 5th 03 03:35 PM


All times are GMT +1. The time now is 05:06 PM.

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"