Thread: Finding range
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default Finding range

On Tue, 08 Nov 2011 07:04:06 -0500, Ron Rosenfeld wrote:

On Mon, 7 Nov 2011 14:00:44 +0100, "Swingleft" wrote:

Hello,

i'm having a small problem...

i need to find the last cell with data in collum E.

and then copy a a pre determent string in a range
from G2 to Gxx where the xx the last row of collum E is.

thanks for all the help..

Swingleft..




If what you want is to return the string in Gxx where xx is the last row of data in column E, that can also be done simply with a worksheet formula:

=LOOKUP(2,1/(LEN($E:$E)1),$G:$G)

If you must do it in code, using the Range.Copy method and Pasting the result to a new destination, something like:

==============
Option Explicit
Sub GString()
Dim rg As Range
Set rg = Cells(Cells.Rows.Count, "E").End(xlUp).Offset(columnoffset:=2)
rg.Copy Destination:=Range("J1")
End Sub
===================



I see from your response to Don that I may have misinterpreted your request. So also try:

=================
Option Explicit
Sub GString()
Dim rg As Range
Const s As String = "HELP"
Set rg = Range("E2", Cells(Cells.Rows.Count, "E").End(xlUp)).Offset(columnoffset:=2)
rg = s
End Sub
=======================