Why does this code sometimes not work?

tjak

Board Regular
Joined
Jan 2, 2003
Messages
117
This code is not being correctly read on a consistent basis and I don't know why. Somedays the alpha split is correct, and somedays, "Barb" gets alpha starting at "J" and sometimes starting at "M". The first split ("Jill") consistently is correct. When "Barb" is wrong, it throws off "Julie".

Can anyone tell me why the "Barb" split is not getting correctly processed
every time?
Is it the code? Is my XL corrupted? Or?

Range("d2").Select
ActiveCell.Formula = "=If(g2>2500,""BETTY"",If(a2<""G"",""JILL"",If(A2>""M"",""BARB"",""JULIE"")))"
Range("d2").Select
Selection.AutoFill Destination:=Range("D2:d" & LastRow)

Thanx.
 
When I added the "Left", I got run-time error "Application defined or Object defined error". I got the same error when I made all the comparisons "Left" and when I used it just on the "Barb" split. Without the "left", the formula runs, but gives "M" to Barb instead of Julie.

The frustration is that I use the identical formula format elsewhere in the code (for another alpha split) and it works fine. Also, this formula worked until 2 days ago. (A1:H1 are headers.) I do an alpha sort of the names after the split.
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
OK, made it work by changing the "Barb" statement to read ">N" which is correctly putting the "M's" to "Julie". How/why this decided to not work after a week I still don't know.

I also don't understand why the code is reading the statement as "=>N" for Barb when I don't have that situation elsewhere in the code.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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