Navigating with a macro

  • Thread starter Thread starter Brian Matlack
  • Start date Start date
B

Brian Matlack

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
 
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
 
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 said:
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
 
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
 
Brian

Sample code.

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

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
 
Back
Top