Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Macro that moves to a cell using two variables See below

Just when I think I know what I'm doing something like this comes along! I
have a macro that needs to move to a cell based on input from the user. The
vaiables are set and working. So What I need to do is set the active cell as
the Rows,Columnx. Can anyone help me with this.

I keep getting " Run Time Error 1004"
"Range' of object '_Global failed"
Here is the line:
Range(Rows, columnx).Select
Both the Rows and Columnx variables are working when I run the macros
step-by-step mode. Any help would be appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Macro that moves to a cell using two variables See below

Rows is a reserved word. Try using a different name for your varaible like
lngRows (assuming you have declared the varaible as type Long).
--
HTH...

Jim Thomlinson


"Mathew" wrote:

Just when I think I know what I'm doing something like this comes along! I
have a macro that needs to move to a cell based on input from the user. The
vaiables are set and working. So What I need to do is set the active cell as
the Rows,Columnx. Can anyone help me with this.

I keep getting " Run Time Error 1004"
"Range' of object '_Global failed"
Here is the line:
Range(Rows, columnx).Select
Both the Rows and Columnx variables are working when I run the macros
step-by-step mode. Any help would be appreciated!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Macro that moves to a cell using two variables See below

Here is a typical way of getting somewhe

Sub get_there()
cl = Application.InputBox("enter column (A,B,...)")
rw = Application.InputBox("enter row (1,2,3...)")
addrs = cl & rw
Range(addrs).Select
End Sub
--
Gary''s Student - gsnu200743


"Mathew" wrote:

Just when I think I know what I'm doing something like this comes along! I
have a macro that needs to move to a cell based on input from the user. The
vaiables are set and working. So What I need to do is set the active cell as
the Rows,Columnx. Can anyone help me with this.

I keep getting " Run Time Error 1004"
"Range' of object '_Global failed"
Here is the line:
Range(Rows, columnx).Select
Both the Rows and Columnx variables are working when I run the macros
step-by-step mode. Any help would be appreciated!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Macro that moves to a cell using two variables See below

Gary's Student: Tried this and it did not work. I also changed the variable
names. Here is what I have: I have a variable named IngRowsxy which equals
an integer between 13 and 31 depending on several other options selected.
The macro is assigning the correct value to this variable. The other
variable is columnxy which is either 4 or 5. This is also working correctly.
I used the step-by-step execution of the macro to verify this. However,
when I try to use the Range(columnxy, IngRowsxy).Select I get the error. I
also tried this: Range(columnxy IngRowsxy).Select So with your code,
below I tried:


addrs = IngRowsxy & "," & columnxy
Range(addrs).Select

and when that failed I tried:

addrs = IngRowsxy & columnxy
Range(addrs).Select

Neither of these worked! Any help would be appreciated.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Macro that moves to a cell using two variables See below

Give this a try...

Cells(IngRowsxy, columnxy).Select

Range takes up to 2 arguments. Each argument is a cell or cell address. Your
code supplies the references to a single cell. You want to use Cells for
that...
--
HTH...

Jim Thomlinson


"Mathew" wrote:

Gary's Student: Tried this and it did not work. I also changed the variable
names. Here is what I have: I have a variable named IngRowsxy which equals
an integer between 13 and 31 depending on several other options selected.
The macro is assigning the correct value to this variable. The other
variable is columnxy which is either 4 or 5. This is also working correctly.
I used the step-by-step execution of the macro to verify this. However,
when I try to use the Range(columnxy, IngRowsxy).Select I get the error. I
also tried this: Range(columnxy IngRowsxy).Select So with your code,
below I tried:


addrs = IngRowsxy & "," & columnxy
Range(addrs).Select

and when that failed I tried:

addrs = IngRowsxy & columnxy
Range(addrs).Select

Neither of these worked! Any help would be appreciated.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Macro that moves to a cell using two variables See below

Jim: Thanks for the help: I changed the variable type to interger and the
new code with cells worked! Again Thanks!

"Jim Thomlinson" wrote:

Give this a try...

Cells(IngRowsxy, columnxy).Select

Range takes up to 2 arguments. Each argument is a cell or cell address. Your
code supplies the references to a single cell. You want to use Cells for
that...
--
HTH...

Jim Thomlinson


"Mathew" wrote:

Gary's Student: Tried this and it did not work. I also changed the variable
names. Here is what I have: I have a variable named IngRowsxy which equals
an integer between 13 and 31 depending on several other options selected.
The macro is assigning the correct value to this variable. The other
variable is columnxy which is either 4 or 5. This is also working correctly.
I used the step-by-step execution of the macro to verify this. However,
when I try to use the Range(columnxy, IngRowsxy).Select I get the error. I
also tried this: Range(columnxy IngRowsxy).Select So with your code,
below I tried:


addrs = IngRowsxy & "," & columnxy
Range(addrs).Select

and when that failed I tried:

addrs = IngRowsxy & columnxy
Range(addrs).Select

Neither of these worked! Any help would be appreciated.

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
Excel macro which prompts for input and moves to a cell - repeated KenZimbo Excel Worksheet Functions 2 September 8th 08 02:02 PM
naming range moves me to macro Martin Excel Programming 1 November 28th 06 12:08 PM
Macro moves data and more!!! Sandeman[_10_] Excel Programming 2 March 21st 06 03:51 PM
Hyperlink-link so that when a cell moves the link also moves? peters Excel Programming 4 March 15th 06 05:26 PM
Macro That Moves Cursor Down job1job1 Excel Programming 3 February 16th 04 09:44 PM


All times are GMT +1. The time now is 04:00 PM.

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"