Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default nested "with .../end with" statements

is it possible to nest "with... / end with" statements ?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default nested "with .../end with" statements

This was a previously posted routine to create subtotals automatically. Note
the nested 'With' near the end

Sub GetSubTotals()

Dim lrow As Long
Dim lcol As Long
Dim i As Integer
Dim MyArray() As Integer

lcol = ActiveSheet.UsedRange.Column - 1 + _
ActiveSheet.UsedRange.Columns.Count
lrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count

ReDim MyArray(2 To lcol)
For i = 2 To lcol
MyArray(i) = i
Next i


With Range(Cells(1, 1), Cells(lrow, lcol))
.Subtotal GroupBy:=1, Function:=xlAverage, TotalList:=MyArray, Replace:=True,
_
PageBreaks:=False, SummaryBelowData:=True

lrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count

Range("A1").Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=RIGHT($A1,7)=""Average"""
With .FormatConditions(1)
.Font.Bold = True
.Font.Italic = False
.Interior.ColorIndex = 19
End With
End With
ActiveSheet.Outline.ShowLevels RowLevels:=2

End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"mark kubicki" wrote in message
...
is it possible to nest "with... / end with" statements ?




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.594 / Virus Database: 377 - Release Date: 24/02/2004


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default nested "with .../end with" statements

thnkx

"Ken Wright" wrote in message
...
This was a previously posted routine to create subtotals automatically.

Note
the nested 'With' near the end

Sub GetSubTotals()

Dim lrow As Long
Dim lcol As Long
Dim i As Integer
Dim MyArray() As Integer

lcol = ActiveSheet.UsedRange.Column - 1 + _
ActiveSheet.UsedRange.Columns.Count
lrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count

ReDim MyArray(2 To lcol)
For i = 2 To lcol
MyArray(i) = i
Next i


With Range(Cells(1, 1), Cells(lrow, lcol))
.Subtotal GroupBy:=1, Function:=xlAverage, TotalList:=MyArray,

Replace:=True,
_
PageBreaks:=False, SummaryBelowData:=True

lrow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count

Range("A1").Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=RIGHT($A1,7)=""Average"""
With .FormatConditions(1)
.Font.Bold = True
.Font.Italic = False
.Interior.ColorIndex = 19
End With
End With
ActiveSheet.Outline.ShowLevels RowLevels:=2

End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

--------------------------------------------------------------------------

--
It's easier to beg forgiveness than ask permission :-)
--------------------------------------------------------------------------

--



"mark kubicki" wrote in message
...
is it possible to nest "with... / end with" statements ?




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.594 / Virus Database: 377 - Release Date: 24/02/2004




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
nested if statements using "AND" as well as "OR" ibbm Excel Worksheet Functions 3 January 23rd 09 08:17 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Need more than 7 nested "IF" statements in Excel" James A Excel Discussion (Misc queries) 1 December 17th 06 02:02 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


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