Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Why Doesn't This Nested "with" work?

Why do I get an "End with without With" error on this? Assume that all the
other work is correct in this snippet, but I get the error on the final end
with. This is in a UserForm procedure when the user clicks an OK button, if
that matters. According to the Help, you can nest with commands.....


With rngCoOwners
.Sort Key1:="Last Name", Order1:=xlAscending, Key2:="First
Name",_ Order2:=xlAscending, Header:=xlYes
For intCounter = 1 To .Rows.Count
If .Cells(intCounter, 12) = "Yes" Then
Set wkshtCoOwnerStatement =
ActiveWorkbook.Worksheets(.Cells_(intCounter, 2) & ", " &
Left(.Cells(intCounter, 3), 1))
Set rngStatementHeader =
wkshtCoOwnerStatement.Range_("tblStatementHeader")
With rngStatementHeader
.Cells(rngStatementHeader.Rows.Count, 1).Value =
"Send Check_ Payable to: Happy Hollow RV Resort, " & Me.txtboxReturnAddress
End With
End If 'check to see if they are current
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Why Doesn't This Nested "with" work?

Ignore the _ characters in there, I put them in based on the wordwrap of the
message positing page, then it formatted them differently when it posted to
the site.....

"Steve Haack" wrote:

Why do I get an "End with without With" error on this? Assume that all the
other work is correct in this snippet, but I get the error on the final end
with. This is in a UserForm procedure when the user clicks an OK button, if
that matters. According to the Help, you can nest with commands.....


With rngCoOwners
.Sort Key1:="Last Name", Order1:=xlAscending, Key2:="First
Name",_ Order2:=xlAscending, Header:=xlYes
For intCounter = 1 To .Rows.Count
If .Cells(intCounter, 12) = "Yes" Then
Set wkshtCoOwnerStatement =
ActiveWorkbook.Worksheets(.Cells_(intCounter, 2) & ", " &
Left(.Cells(intCounter, 3), 1))
Set rngStatementHeader =
wkshtCoOwnerStatement.Range_("tblStatementHeader")
With rngStatementHeader
.Cells(rngStatementHeader.Rows.Count, 1).Value =
"Send Check_ Payable to: Happy Hollow RV Resort, " & Me.txtboxReturnAddress
End With
End If 'check to see if they are current
End With

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Why Doesn't This Nested "with" work?

Necer mind, I figured it out. I forgot the next to go with the counter loop.

"Steve Haack" wrote:

Ignore the _ characters in there, I put them in based on the wordwrap of the
message positing page, then it formatted them differently when it posted to
the site.....

"Steve Haack" wrote:

Why do I get an "End with without With" error on this? Assume that all the
other work is correct in this snippet, but I get the error on the final end
with. This is in a UserForm procedure when the user clicks an OK button, if
that matters. According to the Help, you can nest with commands.....


With rngCoOwners
.Sort Key1:="Last Name", Order1:=xlAscending, Key2:="First
Name",_ Order2:=xlAscending, Header:=xlYes
For intCounter = 1 To .Rows.Count
If .Cells(intCounter, 12) = "Yes" Then
Set wkshtCoOwnerStatement =
ActiveWorkbook.Worksheets(.Cells_(intCounter, 2) & ", " &
Left(.Cells(intCounter, 3), 1))
Set rngStatementHeader =
wkshtCoOwnerStatement.Range_("tblStatementHeader")
With rngStatementHeader
.Cells(rngStatementHeader.Rows.Count, 1).Value =
"Send Check_ Payable to: Happy Hollow RV Resort, " & Me.txtboxReturnAddress
End With
End If 'check to see if they are current
End With

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Why Doesn't This Nested "with" work?

I'm glad to see that I am not the only one that posts a question then shortly
after that, not being able to give it a rest, figure out the answer :)
--
Regards,
John


"Steve Haack" wrote:

Necer mind, I figured it out. I forgot the next to go with the counter loop.

"Steve Haack" wrote:

Ignore the _ characters in there, I put them in based on the wordwrap of the
message positing page, then it formatted them differently when it posted to
the site.....

"Steve Haack" wrote:

Why do I get an "End with without With" error on this? Assume that all the
other work is correct in this snippet, but I get the error on the final end
with. This is in a UserForm procedure when the user clicks an OK button, if
that matters. According to the Help, you can nest with commands.....


With rngCoOwners
.Sort Key1:="Last Name", Order1:=xlAscending, Key2:="First
Name",_ Order2:=xlAscending, Header:=xlYes
For intCounter = 1 To .Rows.Count
If .Cells(intCounter, 12) = "Yes" Then
Set wkshtCoOwnerStatement =
ActiveWorkbook.Worksheets(.Cells_(intCounter, 2) & ", " &
Left(.Cells(intCounter, 3), 1))
Set rngStatementHeader =
wkshtCoOwnerStatement.Range_("tblStatementHeader")
With rngStatementHeader
.Cells(rngStatementHeader.Rows.Count, 1).Value =
"Send Check_ Payable to: Happy Hollow RV Resort, " & Me.txtboxReturnAddress
End With
End If 'check to see if they are current
End With

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
=SUBSTITUTE(C4,"~?#","") will this work to remove multiple string Raja Mahendiran S Excel Worksheet Functions 6 May 12th 10 09:10 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
Too many nested "IF"'s: a work around needed for this example... Bullman Excel Discussion (Misc queries) 5 July 21st 06 02:59 AM
pictures to work with "data" "sort" option arad Excel Discussion (Misc queries) 1 April 18th 06 09:15 PM
Why doesn't "Workbook.Range("myrange").value" work? Brad Patterson Excel Programming 0 July 9th 03 01:24 AM


All times are GMT +1. The time now is 03:41 AM.

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

About Us

"It's about Microsoft Excel"