ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code is working in one file but not in another. (https://www.excelbanter.com/excel-programming/295398-re-code-working-one-file-but-not-another.html)

shilps

Code is working in one file but not in another.
 

Hi Everyone!!
This is my desperate cry for help. I have been trying to correct a cod
for aorund a month. I have only removed repeated actions and reduce
the code size by half. But now the code is behaving very strangely.
have checked and rechecked.....but there is absolutely no error.
I have posted for different problems but everytime I have got
different solution but no answer why this code is wrong. So far no on
has said that code is wrong but they have given me alternate solutions
This doesn't lead me newhere for two reasons: I don't learn ab
programming 'coz I am not able to find the error. And then, thei
solution also doesn't work( sorry folks, but thats the way it is. I
might be working for U, but not on my PC). BTW I am using Excel 2000 o
win 2000, if U think that it might be a source of my woes( then why i
the same code working in other file?)
Now if anyone has time and the will, I simply want someone to compar
the codes and let me know WHERE and WHAT is the problem?
Thankyou so much for having the patience to read through,
Waiting for help desperately
Shilp

+----------------------------------------------------------------
| Attachment filename: code compare.doc
|Download attachment: http://www.mcse.ms/attachment.php?postid=1463457
+----------------------------------------------------------------

-
shilp
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message579280.htm


BrianB

Code is working in one file but not in another.
 
Sorry - most of us do not download files.
You will probably need to copy/paste your code.
Bear in mind that the error may not be in the code itself but in th
availability of the ranges/sheets etc.

The biggest cause of error here is "lazy programming", wher
worksheets/ranges are not explicitly or fully coded eg :-

'--------------------------------------------------------------------------------
MyValue
Workbooks("Book1.xls").WorkSheets("Sheet1").Range( "A1").Value
'--------------------------------------------------------------------------------
where this would save a lot of typing :-
Dim MySheet as WorkSheet
Set MySheet = Workbooks("Book1.xls").WorkSheets("Sheet1")
'--------------------------------------------------------------------------------

As you progress in writing code, you should be using this metho
instead of "Select" unless you actually need to see something in
worksheet

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 08:31 AM.

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