Problem transferring Excel macros to another language

S

svenstar

I try to transfer an Excel application from an German version of Excel 2000
into an English version of Excel 2002. Except for some stupid problems with
use of some functions where options or formats inside "quotes" have to be
modified manually simple spreadsheets works OK.

However when using macros I get error messages of following type:
Run-time error '-2147319784 (80028018)'
Method 'Select' of object '_Worksheet' failed

(code used "Sheets("leave").Select")

The second line varies according to the method used (e.g Method 'Activate'
of object 'Windows' for code ''Windows(fno).Activate" or Method 'Goto' of
object '_Application' for code "Application.Goto Reference:="R2C1" ").

Note that when I set up a new spread sheet exactly the same code works as
intended!

What is the reason, and how can I make the application run without total
rewriting (it is a quite complex application)?
 
P

Patrick Molloy

generally it is not necessary to Activate (or Select) worksheets or
cells/ranges in order to use them

eg
Worksheets("Sheet1").Activate
Range"("A1").Select
Selection.Value = "Hello World"

is the same as

Worksheets("Sheet1").Range"("A1").Value = "Hello World"

if there's a lot of manupulation, use WITH / END WITH

WITH Worksheets("Sheet1")
WITH .Range"("A1")
.Value = "Hello World"
.Interior.Color = vbRed
.Font.Bold = TRUE
END WITH
.Range("A2") = Now
END WITH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top