Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default cell references in vba

I am trying to select a cell I know it is a certain amount of columns to the
right of column "i" (variable called laps) and a set number of rows down
(variable called done).

Effectively i want is .Range("i"+laps & done). What is the correct code for
this.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default cell references in vba

hi,
post all of your code.

Regards
FSt1

"NDBC" wrote:

I am trying to select a cell I know it is a certain amount of columns to the
right of column "i" (variable called laps) and a set number of rows down
(variable called done).

Effectively i want is .Range("i"+laps & done). What is the correct code for
this.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default cell references in vba

Use OFFSET; For example

Range("A1").Offset(5,2).Select will select 5 the cells 5 rows down and 2
columns right.

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I am trying to select a cell I know it is a certain amount of columns to the
right of column "i" (variable called laps) and a set number of rows down
(variable called done).

Effectively i want is .Range("i"+laps & done). What is the correct code for
this.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default cell references in vba

Private Sub Sort_Click()

Dim MaxLap As Integer
Dim Rdone As Integer
Dim Onlap As Integer
Dim tl As Integer
Dim br As Integer



'A Grade
Worksheets("A Grade").Range("G5:IV104").Sort Key1:=Worksheets("A
Grade").Range("I5"), Order1:=xlDescending, _
DataOption1:=xlSortNormal

MaxLap = Worksheets("A Grade").Range("I5")
Rdone = 0
If MaxLap 0 Then
For l = MaxLap To 1
Onlap = WorksheetFunction.CountIf(Worksheets("A Grade").Range("I5:I104"), l)
If Onlap 0 Then
tl = 5 + Rdone
br = 4 + Onlap + Rdone
Worksheets("A Grade").Range("G" & tl & ":IV" & br).Sort Key1:=Worksheets("A
Grade").Range(("i" + Onlap) & tl), Order1:=xlascending,
DataOption1:=xlSortNormal
Rdone = Rdone + Onlap
End If
Next l
End If


A very brief explanation of what is happening. There is a list of riders
with lap times adjacent. The riders can all have varying amounts of laps.
Column i is the number of laps completed. First i sort by number of laps
completed in descending order. Then I am trying to sort the sub groups of
riders who have finished the same amount of laps by the time they finished
their last lap (furthest used column to the right of column I) in ascending
order. Hope this helps a bit.



"NDBC" wrote:

I am trying to select a cell I know it is a certain amount of columns to the
right of column "i" (variable called laps) and a set number of rows down
(variable called done).

Effectively i want is .Range("i"+laps & done). What is the correct code for
this.

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default cell references in vba

I hit 'Post' before intended.

Use OFFSET; For example

Range("A1").Offset(5,2).Select will select the cell 5 rows down and 2
columns right ie; C6

In your case it would be

Range("I1").Offset(done,laps).Select
OR may be
Range("I1").Offset(done-1,laps-1).Select


If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Use OFFSET; For example

Range("A1").Offset(5,2).Select will select 5 the cells 5 rows down and 2
columns right.

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I am trying to select a cell I know it is a certain amount of columns to the
right of column "i" (variable called laps) and a set number of rows down
(variable called done).

Effectively i want is .Range("i"+laps & done). What is the correct code for
this.

Thanks



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default cell references in vba


It's obvious when you put it in front of me. What annoys me is I even have
that in some of my other code. Thank you.


"Jacob Skaria" wrote:

Use OFFSET; For example

Range("A1").Offset(5,2).Select will select 5 the cells 5 rows down and 2
columns right.

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I am trying to select a cell I know it is a certain amount of columns to the
right of column "i" (variable called laps) and a set number of rows down
(variable called done).

Effectively i want is .Range("i"+laps & done). What is the correct code for
this.

Thanks

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default cell references in vba

Range(Cells(x,y),Cells(x+5,y+5)).Select


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
convert relative cell references to absolute cell references via amacro? Dave F[_2_] Excel Discussion (Misc queries) 1 May 15th 08 04:43 PM
Help with converting a block of cells with Absolute and mixed references to relative references Vulcan Excel Worksheet Functions 3 December 13th 07 11:43 PM
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM
Changing Cell References To a Different Worksheet in the Same Cell DL Excel Worksheet Functions 3 March 30th 06 11:18 PM
Transferring cell content between workbooks using cell references Kiwi Mike Excel Discussion (Misc queries) 2 November 27th 04 11:31 PM


All times are GMT +1. The time now is 11:07 PM.

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

About Us

"It's about Microsoft Excel"