Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Rnd() 1004 error

Hi everyone!

I have one old workbook and it contains following piece of code:

Cells(6, Sel_C + 2) = "=" & VBA.Rnd() & "*" & Cells(5, Sel_C +
2).Address

On my machine it works fine, but when I send this workbook to my
colleague above mentioned line generates 1004 error. So I replaced
previous code with following one:

Cells(6, Sel_C + 2) = "=" & (Application.WorksheetFunction.RandBetween
(0, 10000000) / 10000000) & "*" & Cells(5, Sel_C + 2).Address

And now everything works fine.

Does this all mean that my colleague does not have VBA library at all?
Is it possible? Any thoughts?

Thanks!

Shahin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Rnd() 1004 error

Is your colleague using a Mac with Excel 2008 by any chance?

--
Rick (MVP - Excel)


"Shahin Musayev" wrote in message
...
Hi everyone!

I have one old workbook and it contains following piece of code:

Cells(6, Sel_C + 2) = "=" & VBA.Rnd() & "*" & Cells(5, Sel_C +
2).Address

On my machine it works fine, but when I send this workbook to my
colleague above mentioned line generates 1004 error. So I replaced
previous code with following one:

Cells(6, Sel_C + 2) = "=" & (Application.WorksheetFunction.RandBetween
(0, 10000000) / 10000000) & "*" & Cells(5, Sel_C + 2).Address

And now everything works fine.

Does this all mean that my colleague does not have VBA library at all?
Is it possible? Any thoughts?

Thanks!

Shahin


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Rnd() 1004 error

On Nov 13, 9:27*am, "Rick Rothstein"
wrote:
Is your colleague using a Mac with Excel 2008 by any chance?

--
Rick (MVP - Excel)

"Shahin Musayev" wrote in message

...

Hi everyone!


I have one old workbook and it contains following piece of code:


Cells(6, Sel_C + 2) = "=" & VBA.Rnd() & "*" & Cells(5, Sel_C +
2).Address


On my machine it works fine, but when I send this workbook to my
colleague above mentioned line generates 1004 error. So I replaced
previous code with following one:


Cells(6, Sel_C + 2) = "=" & (Application.WorksheetFunction.RandBetween
(0, 10000000) / 10000000) & "*" & Cells(5, Sel_C + 2).Address


And now everything works fine.


Does this all mean that my colleague does not have VBA library at all?
Is it possible? Any thoughts?


Thanks!


Shahin


No. Windows Vista + Office 2007
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Rnd() 1004 error

When I see VBA.Rnd (or any VBA.xxx) in someone's code, I think that they're
doing something to avoid another problem.

I would have expected to see:

Cells(6, Sel_C + 2).Formula = "=" & Rnd & "*" & Cells(5, Sel_C + 2).Address

I'd look at the colleague's pc and do this:

Open the excel and your workbook
Open the VBE and select your workbook's project.
Then click on: Tools|References
Look for MISSING reference.

Uncheck that missing reference.

The missing reference may not (usually doesn't) have anything to do with the
line that caused the error.

If you're not using that reference, you can go back to your pc and remove it and
then redistribute the workbook.

If you're using that reference, you'll have more work to do for the troublesome
pc's.

Shahin Musayev wrote:

Hi everyone!

I have one old workbook and it contains following piece of code:

Cells(6, Sel_C + 2) = "=" & VBA.Rnd() & "*" & Cells(5, Sel_C +
2).Address

On my machine it works fine, but when I send this workbook to my
colleague above mentioned line generates 1004 error. So I replaced
previous code with following one:

Cells(6, Sel_C + 2) = "=" & (Application.WorksheetFunction.RandBetween
(0, 10000000) / 10000000) & "*" & Cells(5, Sel_C + 2).Address

And now everything works fine.

Does this all mean that my colleague does not have VBA library at all?
Is it possible? Any thoughts?

Thanks!

Shahin


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Rnd() 1004 error

It will be difficult to look at colleague's pc: we are in the
different offices, different countries :)

Thing is that workbook has only basic references: VBA, Excel, Office,
stole + MSForms . I don't think that they can become missing. Is it
possible?
Thing is that IT policy is the same in all offices thus my colleague's
pc configuration should not differ from my pc configuration.

Also despite the fact that line:

Cells(6, Sel_C + 2) = "=" & VBA.Rnd() & "*" & Cells(5, Sel_C +
2).Address

looks not very accurate (it is an old workbook) the problem is not in
the missing ".Formula" property. This property is omitted all around
the code but only above mentioned line cause error. And as for VBA.Rnd
()... well at the beginning it was just Rnd() and I added "VBA." just
in case, because I didn't have any other thoughts :)

Any other ideas?

Thanks.

Shahin

On Nov 13, 3:05*pm, Dave Peterson wrote:
When I see VBA.Rnd (or any VBA.xxx) in someone's code, I think that they're
doing something to avoid another problem.

I would have expected to see:

Cells(6, Sel_C + 2).Formula = "=" & Rnd & "*" & Cells(5, Sel_C + 2).Address

I'd look at the colleague's pc and do this:

Open the excel and your workbook
Open the VBE and select your workbook's project.
Then click on: *Tools|References
Look for MISSING reference.

Uncheck that missing reference. *

The missing reference may not (usually doesn't) have anything to do with the
line that caused the error.

If you're not using that reference, you can go back to your pc and remove it and
then redistribute the workbook.

If you're using that reference, you'll have more work to do for the troublesome
pc's.



Shahin Musayev wrote:

Hi everyone!


I have one old workbook and it contains following piece of code:


Cells(6, Sel_C + 2) = "=" & VBA.Rnd() & "*" & Cells(5, Sel_C +
2).Address


On my machine it works fine, but when I send this workbook to my
colleague above mentioned line generates 1004 error. So I replaced
previous code with following one:


Cells(6, Sel_C + 2) = "=" & (Application.WorksheetFunction.RandBetween
(0, 10000000) / 10000000) & "*" & Cells(5, Sel_C + 2).Address


And now everything works fine.


Does this all mean that my colleague does not have VBA library at all?
Is it possible? Any thoughts?


Thanks!


Shahin


--

Dave Peterson




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Rnd() 1004 error

Call the other user and ask them to look for missing references.

Maybe you can have remote access to see for yourself.

Shahin Musayev wrote:

It will be difficult to look at colleague's pc: we are in the
different offices, different countries :)

Thing is that workbook has only basic references: VBA, Excel, Office,
stole + MSForms . I don't think that they can become missing. Is it
possible?
Thing is that IT policy is the same in all offices thus my colleague's
pc configuration should not differ from my pc configuration.

Also despite the fact that line:

Cells(6, Sel_C + 2) = "=" & VBA.Rnd() & "*" & Cells(5, Sel_C +
2).Address

looks not very accurate (it is an old workbook) the problem is not in
the missing ".Formula" property. This property is omitted all around
the code but only above mentioned line cause error. And as for VBA.Rnd
()... well at the beginning it was just Rnd() and I added "VBA." just
in case, because I didn't have any other thoughts :)

Any other ideas?

Thanks.

Shahin

On Nov 13, 3:05 pm, Dave Peterson wrote:
When I see VBA.Rnd (or any VBA.xxx) in someone's code, I think that they're
doing something to avoid another problem.

I would have expected to see:

Cells(6, Sel_C + 2).Formula = "=" & Rnd & "*" & Cells(5, Sel_C + 2).Address

I'd look at the colleague's pc and do this:

Open the excel and your workbook
Open the VBE and select your workbook's project.
Then click on: Tools|References
Look for MISSING reference.

Uncheck that missing reference.

The missing reference may not (usually doesn't) have anything to do with the
line that caused the error.

If you're not using that reference, you can go back to your pc and remove it and
then redistribute the workbook.

If you're using that reference, you'll have more work to do for the troublesome
pc's.



Shahin Musayev wrote:

Hi everyone!


I have one old workbook and it contains following piece of code:


Cells(6, Sel_C + 2) = "=" & VBA.Rnd() & "*" & Cells(5, Sel_C +
2).Address


On my machine it works fine, but when I send this workbook to my
colleague above mentioned line generates 1004 error. So I replaced
previous code with following one:


Cells(6, Sel_C + 2) = "=" & (Application.WorksheetFunction.RandBetween
(0, 10000000) / 10000000) & "*" & Cells(5, Sel_C + 2).Address


And now everything works fine.


Does this all mean that my colleague does not have VBA library at all?
Is it possible? Any thoughts?


Thanks!


Shahin


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Rnd() 1004 error

Finally the problem is solved.

Thing is that colleague has regional settings that differ from US
English: comma for decimal symbol and dot for digit grouping.
It appears that Rnd() return is in local format (decimal symbol -
comma!!!), while Cells(x,y) = or Cells(x,y).Formula expects formula to
be entered in US English.

The solution is simple: add .FormulaLocal where applicable :)

BTW Previous solution with WorksheetFunction.RandBetween also didn't
work. I was misinformed by my colleague.

Hope this will be useful.

Regards,
Shahin
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Error when cell A1 is not active and xlInsideVertical border formatthrowing error 1004 [email protected] Excel Programming 7 August 7th 08 08:43 PM
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"