Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copying variable range not working | Excel Programming | |||
Range used in a macro needs to be variable | Excel Worksheet Functions | |||
Macro to copy a specified range to a variable range | Excel Programming | |||
Is it possible to set a variable range in a macro? | About this forum | |||
range value with variable not working? | Excel Programming |