PC Review


Reply
Thread Tools Rate Thread

How do I pass a variable cell reference to a Range Object?

 
 
Paula
Guest
Posts: n/a
 
      1st Nov 2008
I will be choosing the end of data point (over and over) and then offsetting
the active cell by some value. I don't know how to reference that new active
cell so that I can tell another function that that is its destination.

'goes to last cell in data set (Ex: A10)
ActiveCell.SpecialCells(xlLastCell).Select

'active cell 1 down and 9 left (Ex: B1)
ActiveCell.Offset(1, -9).Range("A1").Select

'How do I indicate that Destination is B1, when B1 Changes each time?
Instead of
'"$A$85" I want to give it a relative variable.
Destination:=Range("$A$85"))


NOTE: I thought I could put in something like

Destination:=Range("ActiveCell.SpecialCells(xlLastCell).Select_
ActiveCell.Offset(1, -9).Range("A1").Select" ))
 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      1st Nov 2008
I'm not sure what you're doing with destination, but you could do something
like this

Sub test1()
Dim aWS As Worksheet
Dim myRange As Range
'goes to last cell in data set (Ex: A10)
Set aWS = ActiveSheet

Set myRange = ActiveCell.SpecialCells(xlLastCell)

'active cell 1 down and 9 left (Ex: B1)
Set myRange = Nothing
On Error Resume Next
Set myRange = myRange.Offset(1, -9)
On Error GoTo 0

If Not myRange Is Nothing Then
'Destination:= myRange 'I'm sure there's more to this
End If

End Sub
--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"Paula" wrote:

> I will be choosing the end of data point (over and over) and then offsetting
> the active cell by some value. I don't know how to reference that new active
> cell so that I can tell another function that that is its destination.
>
> 'goes to last cell in data set (Ex: A10)
> ActiveCell.SpecialCells(xlLastCell).Select
>
> 'active cell 1 down and 9 left (Ex: B1)
> ActiveCell.Offset(1, -9).Range("A1").Select
>
> 'How do I indicate that Destination is B1, when B1 Changes each time?
> Instead of
> '"$A$85" I want to give it a relative variable.
> Destination:=Range("$A$85"))
>
>
> NOTE: I thought I could put in something like
>
> Destination:=Range("ActiveCell.SpecialCells(xlLastCell).Select_
> ActiveCell.Offset(1, -9).Range("A1").Select" ))

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      2nd Nov 2008
These two topics are in the VBA help files and will
provide sample code to illustrate how the references work.
You might also want to look at the Offset property and
the example code for that. There are several ways that you
can apply cell references by variables, offset and relative
reference.

1. Referring to Cells Relative to Other Cells
2. How to Reference Cells and Ranges

"Paula" wrote:

> I will be choosing the end of data point (over and over) and then offsetting
> the active cell by some value. I don't know how to reference that new active
> cell so that I can tell another function that that is its destination.
>
> 'goes to last cell in data set (Ex: A10)
> ActiveCell.SpecialCells(xlLastCell).Select
>
> 'active cell 1 down and 9 left (Ex: B1)
> ActiveCell.Offset(1, -9).Range("A1").Select
>
> 'How do I indicate that Destination is B1, when B1 Changes each time?
> Instead of
> '"$A$85" I want to give it a relative variable.
> Destination:=Range("$A$85"))
>
>
> NOTE: I thought I could put in something like
>
> Destination:=Range("ActiveCell.SpecialCells(xlLastCell).Select_
> ActiveCell.Offset(1, -9).Range("A1").Select" ))

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable Cell Range Reference =?Utf-8?B?S2Vu?= Microsoft Excel Worksheet Functions 3 12th Aug 2007 07:35 PM
VLOOKUP variable range cell reference =?Utf-8?B?T2hw?= Microsoft Excel Worksheet Functions 2 3rd Jul 2007 02:52 PM
Re: pass javascript object reference to a session object naijacoder naijacoder Microsoft ASP .NET 0 15th Sep 2004 03:01 AM
Re: pass javascript object reference to a session object Girish bharadwaj Microsoft ASP .NET 0 15th Sep 2004 02:55 AM
Re: pass javascript object reference to a session object Nicholas Paldino [.NET/C# MVP] Microsoft C# .NET 2 14th Sep 2004 10:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:18 PM.