LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Problem with Bob Umlas sub total code. Coming up with user def

The Option Explicit directive must be outside of and before any
procedure (Sub or Function) and before any module-scoped variable.
Just make it the first line of code in the module and it will work.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]



On Tue, 8 Dec 2009 20:59:01 -0800, GaiGauci
wrote:

No I don't. I thought reading the code I had to specify chunk but that's as
far as my thinking took me. I just tried putting in "Option Explicit" but it
now comes up with "compile error. Invalid inside procedure". Am I doing it
wrong?
Gai


"ker_01" wrote:

At first glance, it appears you are using both ans and rg to reference a
range. chunk is either a cell or a range (or row), but isn't defined in the
code you provided.

At the top of your code module, do you have the following statement?
Option Explicit

"GaiGauci" wrote:

I'm hoping someone might help with this. Bob kindly gave me some code but I
keep coming up with a user define error. I have spent a lot of time trying to
figure it out but I haven't worked with "Chunk" before and my trusty manual
isn't helping. My logic is letting me down somewhat too!

Here's what I want to do. Search columns S and T and if both cells are empty
at the same time, then subtotal down in both columns until the next entry in
either column. I also want them to be bold font. Here's the script thus far..

Sub SubTots()
Dim ans As Range
Set ans = Nothing
Set rg = Range("S:T").SpecialCells(xlCellTypeBlanks)
For Each chunk In rg
If chunk.Column = 19 And IsEmpty(chunk.Offset(0, 1)) Or _
chunk.Column = 20 And IsEmpty(chunk.Offset(0, -1)) Then
If ans Is Nothing Then
Set ans = chunk
Else
Set ans = Union(ans, chunk)
End If
End If
Next
ans.Select
Application.SendKeys "%="
End Sub

Can anyone help? Any help appreciated at this stage. This little bit is
holding up a much larger project.
Cheers
Gai

 
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
Count cells with fill color and retain code - Mr. Umlas Can you he Counting Cells With Fill Color[_2_] Excel Discussion (Misc queries) 1 April 4th 08 12:58 AM
Excel 2007 user name not coming up [email protected] Excel Discussion (Misc queries) 0 May 10th 07 03:40 PM
Need VBA Code to Let User Define Active Sheet zulfer7 Excel Discussion (Misc queries) 3 March 29th 07 02:59 PM
Excel User Conference - Early Registration Period Coming to an End Damon Longworth Excel Discussion (Misc queries) 0 July 13th 05 01:21 PM
New user needing help with coming up with a formula Igniter New Users to Excel 2 June 2nd 05 07:10 PM


All times are GMT +1. The time now is 06:41 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"