Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
=SUBSTITUTE(C4,"~?#","") will this work to remove multiple string | Excel Worksheet Functions | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Too many nested "IF"'s: a work around needed for this example... | Excel Discussion (Misc queries) | |||
pictures to work with "data" "sort" option | Excel Discussion (Misc queries) | |||
Why doesn't "Workbook.Range("myrange").value" work? | Excel Programming |