ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   runtime error 13 - unlucky for some! (https://www.excelbanter.com/excel-programming/343670-runtime-error-13-unlucky-some.html)

MoonWeazel[_10_]

runtime error 13 - unlucky for some!
 

afternoon!

this has been bugging me for ages!

am not excellent in vba so please be nice!!

i have a spreadsheet of about 1500 lines and would like to (using
macro) strip out all the records i don't need based a value in one o
the columns.

for example:

column b holds the name of the programme and i only want projects wit
a programme name of either zmxxxx or zmyyyy. the macro i am tryin
(and failing)to write would look at the value of b1, evaluate it an
delete it if it didn't match either zmxxxx or zmyyyy.

the code:

Sub tidy_up()

Const workstream1 As String = "zmxxx"
Const workstream2 As String = "myyyy

Dim project As String

project = activecell

If CStr(project) < CStr(workstream1) Or CStr(workstream2) Then

activecell.EntireRow.Delete

Else

End If

End Sub

i keep getting run time error 13 appear. i can't see where the proble
is as everything matches (as far as my very untrained eye can see!)

please can anyone out there in cyberland help as i have a big dent i
my head from banging it against my desk!

TIA,

MoonWeaze

--
MoonWeaze
-----------------------------------------------------------------------
MoonWeazel's Profile: http://www.excelforum.com/member.php...nfo&userid=211
View this thread: http://www.excelforum.com/showthread.php?threadid=47878


Jim Cone

runtime error 13 - unlucky for some!
 
MW,

Computers are dumb, you have to tell them what to do.<g

"Or CStr(workstream2)" has to stand by itself without assuming
that Excel should know the comparison you want to make.
Also your variables are declared as Strings, so they don't need to be
converted to strings later. Give this a try...
(note the change from "or" to "and")
'--------------------
Sub tidy_up()
Const workstream1 As String = "zmxxx"
Const workstream2 As String = "myyyy"
Dim project As String

project = CStr(ActiveCell.Value)
If project < workstream1 And project < workstream2 Then
ActiveCell.EntireRow.Delete
End If
End Sub
'------------------
Jim Cone
San Francisco, USA



MoonWeazel" wrote...
afternoon!
this has been bugging me for ages!
am not excellent in vba so please be nice!!
i have a spreadsheet of about 1500 lines and would like to (using a
macro) strip out all the records i don't need based a value in one of
the columns.
for example:
column b holds the name of the programme and i only want projects with
a programme name of either zmxxxx or zmyyyy. the macro i am trying
(and failing)to write would look at the value of b1, evaluate it and
delete it if it didn't match either zmxxxx or zmyyyy.
the code:

Sub tidy_up()

Const workstream1 As String = "zmxxx"
Const workstream2 As String = "myyyy

Dim project As String

project = activecell

If CStr(project) < CStr(workstream1) Or CStr(workstream2) Then

activecell.EntireRow.Delete

Else

End If

End Sub

i keep getting run time error 13 appear. i can't see where the problem
is as everything matches (as far as my very untrained eye can see!)
please can anyone out there in cyberland help as i have a big dent in
my head from banging it against my desk!

TIA,
MoonWeazel

MoonWeazel[_11_]

runtime error 13 - unlucky for some!
 

Hey Jim!

Cool and groovy dude!

well impressed!

so close yet so far!

you saved my poor head and my poor desk!

laters!

moonweazel!


--
MoonWeazel
------------------------------------------------------------------------
MoonWeazel's Profile: http://www.excelforum.com/member.php...fo&userid=2119
View this thread: http://www.excelforum.com/showthread...hreadid=478780



All times are GMT +1. The time now is 10:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com