LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
correct syntax for nesting "if", "and", and "vlookup"....if possib Christine Excel Worksheet Functions 4 January 2nd 09 10:43 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"