PDA

View Full Version : [SOLVED] Select Case



bifjamod
03-07-2016, 04:25 PM
I have a Select Case script that is intended to assign a string value based on the value of the cell in row 3 of the selected column. If, for example, I have selected cells F5:F17, the value of F3 should be returned in the Select Case operation. At first glance, the below script seems to work. That is to say, it does work when the selection is in column C....and ONLY column C. I've tried it in other columns, but produce a "Method Range of Object _Application Failed" error.

Can someone offer some guidance on resolving this?



Select Case Cells(aCell.Column, 3).Value
Case "ACCOUNT"
strTarg = "H1"
Case "POL"
strTarg = "H4"
Case "WEIGHT"
strTarg = "J15"
Case "CBM"
strTarg = "J16"
End Select


I can share the rest of the script if you think it has value to the question at hand; however, I don't think it's particularly relevant, as the first line of the above is, I think, the key. I experimented with a variation using Range, but with no success there either. (Probably obvious, but just in case: aCell has been declared as a range....now I'm wondering if that might be part of the problem?)


D'UH! NEVER MIND! I had my cell address backwards!!!! The correct script is:


Select Case Cells(3, aCell.Column).Value