[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Why would the same Excel VBA work different in different computers

Same excel works different in different PC.  Both PC are same specs.

Message "variable not declared"
0
rayluvs
Asked:
rayluvs
1 Solution
 
rayluvsAuthor Commented:
Update


We have an apps that export to excel data.  When exporting, it also creates a module by importing a .BAS.

In one computer works excellent.  In another, it doesn't.  The error is that the variables are not.

But why one PC works the other no.  Both PC are windows 7 and both have office 2007.

Reviewing the problem we thought that it may be that one excel setups the exported excel with "option explicit" while the other doesn't.

This is the closet guess.

What can be causing this problem?
0
 
Saqib Husain, SyedEngineerCommented:
That is just the problem. Either delete the Option explicit or declare the variables.
0
 
chwong67Commented:
Check reference are the same for 2 computers...
Developer->Visual Basic: Tools->references
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello, set option explicit up in both computers. In the VBE click tools > options > always declare variables.

Cheers, teylyn
0
 
VipulKadiaCommented:
In Excel-2007, go to VBE : Tools --> Options --> Editor
There is an option : Require Variable Declaration.
If this option is checked then in VBA code, you will get 'Option Explicit' at the top.
So if this option is checked in that case you have to declare each and every variables.
So in one of the computer, this option is checked so it is giving an error while in another computer this option is NOT CHECKED so that is not giving an error.
0
 
rayluvsAuthor Commented:
Of course, thank you very much!!!  we go about it as as we get to the office!!
0
 
rayluvsAuthor Commented:
Yes it worked!! The excel was created and filled upt certain point.  The following errors:

          Runtime error 1004
          using advance filter, select range

          Runtime error 1004
          Cannot asigne propertis PriuntQuality class PageSetup

We have compared both PC Excel 2007 option and found some differences and made them alike.

But still problem.

Can you shed some light on this?
FilterError.jpg
PageError.jpg
0
 
rayluvsAuthor Commented:
We are tedious comparing excel option and it's VBA options the good and the bad PC to make sure both are same.

Anything else we should consider based on the error messages?
0
 
VipulKadiaCommented:
Hi Ramante,
As you got the answer for your original question, I request you to close this question and as you have another question, please ask it as a separate question.

0
 
rayluvsAuthor Commented:
Prior placing these last two errors of error 1004, we tediously compared the PC Excel Option that display the correct Excel VBA and the PC that doesn't display correctly the Excel VBA.  There were like 3 more that appear after the initial "variable not declared".  These 3 we fixed it and since these last 2 of error 1004 couldn't, we posted to the thread.

Nevertheless, if you want to place another question we'll do.  But what happens if after the error 1004, another appears?

We are checking differences in PC configuration besides the Excel Option or maybe there is another place that relates to the Excel that we should look at?

Please advice
0
 
VipulKadiaCommented:
Ramante,
If you face any other error then post it as an another thread(Question).
0
 
rayluvsAuthor Commented:
Ok will proceed when at office.
0
 
rayluvsAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for Ramante's comment http:/Q_27396195.html#36968334

for the following reason:

Thanx
0
 
VipulKadiaCommented:
Ramante,
I request you to accept the solution, as you already got the solution for your original question. Now, after getting solution to your original question, if another error has occured then you should ask another question.
0
 
rayluvsAuthor Commented:
Sorry about that, I chose the wrong entry for the answer; will close correctly.
0
 
rayluvsAuthor Commented:
Sorry, chose incorrectly.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now