Too many line continuations

techstyle20

New Member
Joined
May 14, 2012
Messages
40
Good Morning,

I was wondering whether anyone could tell me how to add more "Or" statments to the following?

I get the message "Too many line continuations". Is there a more elegant way of testing each of the cells without having to include a new row for each?

Thanks guys,

T.

'Please Selects
If Worksheets("Additional Conditions").Range("F8") <> "- Please Select -" _
Or Worksheets("Additional Conditions").Range("F11") <> "- Please Select -" _
Or Worksheets("Additional Conditions").Range("F14") <> "- Please Select -" _
Or Worksheets("Additional Conditions").Range("F17") <> "- Please Select -" _
Or Worksheets("Additional Conditions").Range("F20") <> "- Please Select -" _
Or Worksheets("Additional Conditions").Range("F43") <> "- Please Select -" _
Or Worksheets("Additional Conditions").Range("F46") <> "- Please Select -" _
Or Worksheets("Additional Conditions").Range("F49") <> "- Please Select -" _
Or Worksheets("Additional Conditions").Range("F52") <> "- Please Select -" _
Or Worksheets("Additional Conditions").Range("F55") <> "- Please Select -" _
Then
Worksheets("Offer Letter Instruction Sheet").Range("P15") = "Additional Conditions"
Else
Worksheets("Offer Letter Instruction Sheet").Range("P15") = ""
End If
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
See if this works better:
Code:
Dim cell As range
With Worksheets("Additional Conditions")
For Each cell In .range("F8", "F11", "F14", "F17", "F20", "F43", "F46", "F49", _
    "F52", "F55")
    Worksheets("Offer Letter Instruction Sheet").range("P15").ClearContents 
    If cell.Value <> "- Please Select -" Then _
        Worksheets("Offer Letter Instruction Sheet").range("P15") = "Additional Conditions"
Next Cell
 
Upvote 0
Because I forgot a line! Try:
Rich (BB code):
Dim cell As range
With Worksheets("Additional Conditions")
  For Each cell In .range("F8", "F11", "F14", "F17", "F20", "F43", "F46", "F49", _
    "F52", "F55")
    Worksheets("Offer Letter Instruction Sheet").range("P15").ClearContents 
    If cell.Value <> "- Please Select -" Then _
        Worksheets("Offer Letter Instruction Sheet").range("P15") = "Additional Conditions"
  Next Cell
End With
 
Upvote 0
I think you may want an Exit For before the Next Cell line.
 
Upvote 0
Because I forgot a line!
And to test?
I think this code has a couple of problems.
1. The range syntax is incorrect.

2. It will populate P15 on the 'Offer' sheet based only on the basis of the final cell in the given range in in the 'Additional Conditions' sheet. My interpretation of the original code is that P15 should only be cleared if every cell in the given range contains "- Please Select -". If so, consider this code

Code:
Sub Test1()
  Dim c As Range
  Dim AddCond As Boolean
  
  Const myCells As String = "F8, F11, F14, F17, F20, " & _
                            "F43, F46, F49, F52, F55"         '<-Can add more here
                            
  For Each c In Worksheets("Additional Conditions").Range(myCells)
    If c.Value <> "- Please Select -" Then AddCond = True
  Next c
  Worksheets("Offer Letter Instruction Sheet").Range("P15").Value _
    = IIf(AddCond, "Additional Conditions", "")
End Sub
 
Last edited:
Upvote 0
Good spot Rory and Peter, I think then mine should be:
Rich (BB code):
Dim cell As range
With Worksheets("Additional Conditions")
  For Each cell In .range("F8, F11, F14, F17, F20, F43, F46, F49, _
    F52, F55")
    Worksheets("Offer Letter Instruction Sheet").range("P15").ClearContents 
    If cell.Value <> "- Please Select -" Then
        Worksheets("Offer Letter Instruction Sheet").range("P15") = "Additional Conditions"
        Exit For
    End If
  Next Cell
End With

As Peter's suggestion shows, a few different approaches to this too
 
Upvote 0
Hi Jack,

Unfortunately this comes up with "Runtime error 450"

"Wrong number of arguments or invalid property assignment"

Could this be a problem with some other part of my code?

T.
 
Upvote 0
Thanks guys,

I tried Peters code there and it works perfectly!

This is a great help for future projects also.

Thanks to you all!

T.
 
Upvote 0

Forum statistics

Threads
1,216,810
Messages
6,132,829
Members
449,761
Latest member
AUSSW

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top