ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Navigating with a macro (https://www.excelbanter.com/excel-programming/291766-navigating-macro.html)

Brian Matlack[_3_]

Navigating with a macro
 
When navigating with a macro:
Example: Activecell.offset(1, 0).Range("A1")Select
Can I somehow have the offset numbers refer to a value in a cell
therefor making them variable based on formula input

--
Message posted from http://www.ExcelForum.com


Ed[_9_]

Navigating with a macro
 
Brian - If you can put your values into Strings, you should be able to use
ActiveCell.Offset(x,y) with x and y being the Strings. So if x and y are
the values in a cell, or the calculated results of a formula, or whatever
else set in a String variable, it should work.

Ed

"Brian Matlack " wrote in
message ...
When navigating with a macro:
Example: Activecell.offset(1, 0).Range("A1")Select
Can I somehow have the offset numbers refer to a value in a cell
therefor making them variable based on formula input?


---
Message posted from http://www.ExcelForum.com/




Bob Phillips[_6_]

Navigating with a macro
 
Ed,

yes

Activecell.offset(Range("X1").Value, 0).Range("A1")Value)Select

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ed" wrote in message
...
Brian - If you can put your values into Strings, you should be able to use
ActiveCell.Offset(x,y) with x and y being the Strings. So if x and y are
the values in a cell, or the calculated results of a formula, or whatever
else set in a String variable, it should work.

Ed

"Brian Matlack " wrote in
message ...
When navigating with a macro:
Example: Activecell.offset(1, 0).Range("A1")Select
Can I somehow have the offset numbers refer to a value in a cell
therefor making them variable based on formula input?


---
Message posted from http://www.ExcelForum.com/






Ed[_9_]

Navigating with a macro
 
Activecell.offset(Range("X1").Value, 0).Range("A1")Value)Select


I know I'm not the brightest student, Bob, but I don't understand. I
created a sheet with A1=1, A2=2, A3=3, and A4=4. Then I used the following
code, and stepped through watching the Active being offset. What did I
miss?

Ed

Sub Test_Offset()

Dim a As String
Dim b As String
Dim c As String
Dim d As String

a = Range("A1").Value
b = Range("A2").Value
c = Range("A3").Value
d = Range("A4").Value

Range("D5").Activate
ActiveCell.Offset(a, b).Select
ActiveCell.Offset(c, d).Select
ActiveCell.Offset(c, b).Select
ActiveCell.Offset(a, d).Select

End Sub



Gord Dibben

Navigating with a macro
 
Brian

Sample code.

Public Sub gronk()
ccols = Range("A1").Value
rrows = Range("B1").Value
ActiveCell.Resize(ccols, rrows).Select
End Sub

On Wed, 18 Feb 2004 11:08:55 -0700, "Ed"
wrote:

Brian - If you can put your values into Strings, you should be able to use
ActiveCell.Offset(x,y) with x and y being the Strings. So if x and y are
the values in a cell, or the calculated results of a formula, or whatever
else set in a String variable, it should work.

Ed

"Brian Matlack " wrote in
message ...
When navigating with a macro:
Example: Activecell.offset(1, 0).Range("A1")Select
Can I somehow have the offset numbers refer to a value in a cell
therefor making them variable based on formula input?


---
Message posted from http://www.ExcelForum.com/




Brian Matlack[_4_]

Navigating with a macro
 
Thanks Gord - Works Great!

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com