B
Ben Martens
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..
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..