Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Compile Error - Procedure too large

I am new to coding and am getting the Compile error message - procedure too
large.

Can anyone advise me how to consense the following code based on a combi box
allowing the user to select a month ?
It is 57 pages long but an extract appears below.

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Columns("O:X").EntireColumn.Hidden = True
Columns("AP:AX").EntireColumn.Hidden = True
Columns("Z:AA").EntireColumn.Hidden = True
Columns("AZ:BA").EntireColumn.Hidden = True
Range("AB15").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB16").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB17").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB18").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"

Many thanks
Dave



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Compile Error - Procedure too large

You can combine ranges and not select cells:

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Range("O:X,AP:AX,Z:AA,AZ:BA").EntireColumn.Hidden = True
Range("AB15").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB16").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB17").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB18").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"

And as long as the formulas are consistent, you can do even mo

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Range("O:X,AP:AX,Z:AA,AZ:BA").EntireColumn.Hidden = True
Range("AB15:ab18").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"



DAVEYB wrote:

I am new to coding and am getting the Compile error message - procedure too
large.

Can anyone advise me how to consense the following code based on a combi box
allowing the user to select a month ?
It is 57 pages long but an extract appears below.

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Columns("O:X").EntireColumn.Hidden = True
Columns("AP:AX").EntireColumn.Hidden = True
Columns("Z:AA").EntireColumn.Hidden = True
Columns("AZ:BA").EntireColumn.Hidden = True
Range("AB15").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB16").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB17").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB18").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"

Many thanks
Dave


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Compile Error - Procedure too large

Stunning answer - many thanks Dave

"Dave Peterson" wrote:

You can combine ranges and not select cells:

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Range("O:X,AP:AX,Z:AA,AZ:BA").EntireColumn.Hidden = True
Range("AB15").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB16").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB17").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB18").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"

And as long as the formulas are consistent, you can do even mo

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Range("O:X,AP:AX,Z:AA,AZ:BA").EntireColumn.Hidden = True
Range("AB15:ab18").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"



DAVEYB wrote:

I am new to coding and am getting the Compile error message - procedure too
large.

Can anyone advise me how to consense the following code based on a combi box
allowing the user to select a month ?
It is 57 pages long but an extract appears below.

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Columns("O:X").EntireColumn.Hidden = True
Columns("AP:AX").EntireColumn.Hidden = True
Columns("Z:AA").EntireColumn.Hidden = True
Columns("AZ:BA").EntireColumn.Hidden = True
Range("AB15").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB16").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB17").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB18").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"

Many thanks
Dave


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Compile Error - Procedure too large

Columns("A:IV").EntireColumn.Hidden = False

You can save a little bit more by removing the .EntireColumn property
call...

Columns("A:IV").Hidden = False

Because the reference it to Columns, it will do the same thing.

--
Rick (MVP - Excel)


"Dave Peterson" wrote in message
...
You can combine ranges and not select cells:

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Range("O:X,AP:AX,Z:AA,AZ:BA").EntireColumn.Hidden = True
Range("AB15").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB16").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB17").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB18").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"

And as long as the formulas are consistent, you can do even mo

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Range("O:X,AP:AX,Z:AA,AZ:BA").EntireColumn.Hidden = True
Range("AB15:ab18").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"



DAVEYB wrote:

I am new to coding and am getting the Compile error message - procedure
too
large.

Can anyone advise me how to consense the following code based on a combi
box
allowing the user to select a month ?
It is 57 pages long but an extract appears below.

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Columns("O:X").EntireColumn.Hidden = True
Columns("AP:AX").EntireColumn.Hidden = True
Columns("Z:AA").EntireColumn.Hidden = True
Columns("AZ:BA").EntireColumn.Hidden = True
Range("AB15").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB16").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB17").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB18").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"

Many thanks
Dave


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Compile Error - Procedure too large

Rick, Congrats on your deserved MVP.

BTW, Didn't I say this in my OP?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rick Rothstein" wrote in message
...
Columns("A:IV").EntireColumn.Hidden = False


You can save a little bit more by removing the .EntireColumn property
call...

Columns("A:IV").Hidden = False

Because the reference it to Columns, it will do the same thing.

--
Rick (MVP - Excel)


"Dave Peterson" wrote in message
...
You can combine ranges and not select cells:

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Range("O:X,AP:AX,Z:AA,AZ:BA").EntireColumn.Hidden = True
Range("AB15").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB16").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB17").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB18").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"

And as long as the formulas are consistent, you can do even mo

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Range("O:X,AP:AX,Z:AA,AZ:BA").EntireColumn.Hidden = True
Range("AB15:ab18").FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"



DAVEYB wrote:

I am new to coding and am getting the Compile error message - procedure
too
large.

Can anyone advise me how to consense the following code based on a combi
box
allowing the user to select a month ?
It is 57 pages long but an extract appears below.

Private Sub ComboBox1_Change()
Columns("A:IV").EntireColumn.Hidden = False
If ComboBox1 = "JANUARY" Then
Columns("O:X").EntireColumn.Hidden = True
Columns("AP:AX").EntireColumn.Hidden = True
Columns("Z:AA").EntireColumn.Hidden = True
Columns("AZ:BA").EntireColumn.Hidden = True
Range("AB15").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB16").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB17").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"
Range("AB18").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-23]:RC[-14])"

Many thanks
Dave


--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Compile Error - Procedure too large

BTW, Didn't I say this in my OP?

Yes, but I responded to Dave's posting before I read your response (I
scanned his code, saw the simplification and posted my comment about it
right then and there).

Rick, Congrats on your deserved MVP.


Thank you very much for your extremely kind comment; I really appreciate it.
However, you might want to go to the microsoft.private.mvp.excel newsgroup
and read the Nate Oliver sub-thread in the main thread with Subject line
"New Excel pages on MSDN" dated 8/26/2008 for the (strange) story behind my
being able to use this signature.

--
Rick (MVP - Excel)

Reply
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
Compile Error: Procedure too large Corey ....[_2_] Excel Programming 1 July 25th 08 09:53 AM
VBA Compile error: Procedure too large? Jerry Dyben Excel Discussion (Misc queries) 1 October 31st 05 10:15 PM
Compile error: Procedure too large BHARATH RAJAMANI Excel Programming 2 August 24th 05 10:24 PM
Compile error: Procedure too large Susan Hayes Excel Programming 2 May 20th 05 05:01 PM
Compile Error: Procedure too large mate Excel Programming 2 May 18th 04 04:30 PM


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