Run Macro in other computer

  • Thread starter Thread starter hurriance
  • Start date Start date
H

hurriance

I had finished a macro, it works well in my computer. However,
when i try it in other computer, it does not work.

and the code cannot work is the following :

Range("I1").Select
ActiveCell.FormulaR1C1 = "Month"
ActiveCell.Offset(0, 1) = "=mid(sheet1!g2,4,2)"
ActiveCell.Offset(0, 1).Copy
ActiveCell.Offset(0, 1).PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks :=False, Transpose:=False

why did this situation occur? and How to sovle it?
 
There are hundreds of ways things "does not work" in a computer, please be
more specific. Maybe you are getting an error message, the content of it
should in theory tell what's wrong.

HTH. Best wishes Harald
 
hurriance said:
I had finished a macro, it works well in my computer. However,
when i try it in other computer, it does not work.

and the code cannot work is the following :

Range("I1").Select
ActiveCell.FormulaR1C1 = "Month"
ActiveCell.Offset(0, 1) = "=mid(sheet1!g2,4,2)"
ActiveCell.Offset(0, 1).Copy
ActiveCell.Offset(0, 1).PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks :=False, Transpose:=False

why did this situation occur? and How to sovle it?

This code worked fine for me in Excel 2003 with WinXP Home SP2. Are you
running it in the same workbook on both computers? What error are you
getting? If it's running in a different workbook on the non-working PC, is
there actually a sheet called "sheet1" in that workbook?
 
I find that run well in excel XP, but not Excel 2000.
Actually, the G2 in Sheet1 store the date e.g. 01-05-2006
the code "=mid(sheet1!g2,4,2)" want to get the value of month.
But in excel 2000, it does work properly, it give the value 50 instead
of 05.
What change should I make in order to make it work in Excel 2000.
 
hurriance said:
I find that run well in excel XP, but not Excel 2000.
Actually, the G2 in Sheet1 store the date e.g. 01-05-2006
the code "=mid(sheet1!g2,4,2)" want to get the value of month.
But in excel 2000, it does work properly, it give the value 50 instead
of 05.
What change should I make in order to make it work in Excel 2000.

That won't give you the month - at least not if cell g2 is formatted as
Date. Dates are stored as numbers in Excel, and that function will return
the 4th and 5th digits of the number that represents the date - not the
month. Use Month() instead - this is a Worksheet function as well as a VBA
function. Then format the output as "0#" if you want a leading 0 for months
1 to 9.
 

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

Back
Top