Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Variable Range in Macro not working.

Hi all,
I´m trying to select a range by using 2 integer variables and I get
the following Error msg
----------------------------------------------------
Run-time error '1004':

Application-defined or object-defined error
----------------------------------------------------

The sitax is as follows:

Range("A" & fila & ":" & "F" & ultimafila).Select

Should i type it in a different way ?
All suggestions welcome.
BR.
NICOLAS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Variable Range in Macro not working.

The syntax you have should work (not the way i would do it but it should
work). The only thing I would add is that the variable values can not be 0
and must be less than 65,536... To that end you should be using long and not
integer as integer ends at 32k... If it was me I would be more inclined to do
something like...

Range(cells(fila, "A"), cells(ultimafila, "F")).Select

--
HTH...

Jim Thomlinson


"Nicolas" wrote:

Hi all,
I´m trying to select a range by using 2 integer variables and I get
the following Error msg
----------------------------------------------------
Run-time error '1004':

Application-defined or object-defined error
----------------------------------------------------

The sitax is as follows:

Range("A" & fila & ":" & "F" & ultimafila).Select

Should i type it in a different way ?
All suggestions welcome.
BR.
NICOLAS

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Variable Range in Macro not working.

| Hi all,
| I´m trying to select a range by using 2 integer variables and I get
| the following Error msg
| ----------------------------------------------------
| Run-time error '1004':
|
| Application-defined or object-defined error
| ----------------------------------------------------
|
| The sitax is as follows:
|
| Range("A" & fila & ":" & "F" & ultimafila).Select
|

after you press debug button the debbuger stops on the line above ? in my
sheet the same code works fine
(I assume that these 2 variables give in fact proper values and u monitor it
somehow)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Variable Range in Macro not working.

Hi Jim,

thnx for ur reply in a first place, I´ve tried the code you suggested
and the result is exactly the same. But if i use the porperty COPY instead of
SELECT it doesn´t return the error. Any reason why this should be happening ?
(I´m running Excel 2003)
Tnhx.

"Jim Thomlinson" wrote:

The syntax you have should work (not the way i would do it but it should
work). The only thing I would add is that the variable values can not be 0
and must be less than 65,536... To that end you should be using long and not
integer as integer ends at 32k... If it was me I would be more inclined to do
something like...

Range(cells(fila, "A"), cells(ultimafila, "F")).Select

--
HTH...

Jim Thomlinson


"Nicolas" wrote:

Hi all,
I´m trying to select a range by using 2 integer variables and I get
the following Error msg
----------------------------------------------------
Run-time error '1004':

Application-defined or object-defined error
----------------------------------------------------

The sitax is as follows:

Range("A" & fila & ":" & "F" & ultimafila).Select

Should i type it in a different way ?
All suggestions welcome.
BR.
NICOLAS

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Variable Range in Macro not working.

By the way, just figured out thar i get the same error with code as simple as
cells(1,1).select range ("A1").select, etc.
Any clues on this ? (it´s driving me insane........)

"Nicolas" wrote:

Hi Jim,

thnx for ur reply in a first place, I´ve tried the code you suggested
and the result is exactly the same. But if i use the porperty COPY instead of
SELECT it doesn´t return the error. Any reason why this should be happening ?
(I´m running Excel 2003)
Tnhx.

"Jim Thomlinson" wrote:

The syntax you have should work (not the way i would do it but it should
work). The only thing I would add is that the variable values can not be 0
and must be less than 65,536... To that end you should be using long and not
integer as integer ends at 32k... If it was me I would be more inclined to do
something like...

Range(cells(fila, "A"), cells(ultimafila, "F")).Select

--
HTH...

Jim Thomlinson


"Nicolas" wrote:

Hi all,
I´m trying to select a range by using 2 integer variables and I get
the following Error msg
----------------------------------------------------
Run-time error '1004':

Application-defined or object-defined error
----------------------------------------------------

The sitax is as follows:

Range("A" & fila & ":" & "F" & ultimafila).Select

Should i type it in a different way ?
All suggestions welcome.
BR.
NICOLAS



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Variable Range in Macro not working.

very strange!
check the references in VBA editor (tools\references) maybe you don't have
references set to apropriate libraries...


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Variable Range in Macro not working.

I know, i had to overcome the problem by referencing the whole code...
Worksheets("Blk Cont D Historico").Range(Worksheets("Blk Cont D
Historico").Cells(fila, "A"), Worksheets("Blk Cont D
Historico").Cells(ultimafila, "F")).Select

now it works, but it is still pretty anoying.
Thanks anyway for your help guys.

"Snake Plissken" wrote:

very strange!
check the references in VBA editor (tools\references) maybe you don't have
references set to apropriate libraries...



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
copying variable range not working Susan Excel Programming 2 October 27th 06 05:42 PM
Range used in a macro needs to be variable DaveP Excel Worksheet Functions 3 November 4th 05 03:23 PM
Macro to copy a specified range to a variable range SWT Excel Programming 4 October 21st 05 08:24 PM
Is it possible to set a variable range in a macro? Mary About this forum 0 June 12th 05 06:26 PM
range value with variable not working? James[_24_] Excel Programming 5 October 4th 04 02:43 PM


All times are GMT +1. The time now is 01:51 AM.

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

About Us

"It's about Microsoft Excel"