Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using "Like"
I have a bunch of spreadsheets with expense data on it and
wrote some code to go through cells and find expenses that are salary related. The code worked fine in the original module I created it in but when I copy/paste the code into another module in another file and run it, it doesn't work anymore. I can not figure out why the same code won't work in any other files/modules, it just doesn't make any sense to me. I know I can simply just run the code in the original file on all the spreadsheets I need to do this on but, for convience sake I would like to just use the same code in other modules/files. Not to mention that I simply want to understand why this won't work when I copy/paste the code into another module/file. Below is the code I wrote: Private Sub AddCode() Dim liRow As Integer, myTest liRow = 9 Do If Range("CA" & liRow).Value < Empty Then myTest = Range("CB" & liRow).Value Like "*salaries*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CB" & liRow).Value Like "*salary*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CD" & liRow).Value Like "*salaries*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CD" & liRow).Value Like "*salary*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CF" & liRow).Value Like "*salaries*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CF" & liRow).Value Like "*salary*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CH" & liRow).Value Like "*salaries*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CH" & liRow).Value Like "*salary*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CJ" & liRow).Value Like "*salaries*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CJ" & liRow).Value Like "*salary*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CL" & liRow).Value Like "*salaries*" If myTest = True Then Range("CM" & liRow).Value = "S" End If myTest = Range("CL" & liRow).Value Like "*salary*" If myTest = True Then Range("CM" & liRow).Value = "S" End If End If liRow = liRow + 1 Loop End Sub Does anybody have any ideas why what I am doing won't work, I am completely dumbfounded.. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
correct syntax for nesting "if", "and", and "vlookup"....if possib | 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) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel |