Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using .resize or an offset


I'm looking to create a routine that opens up external worksheet an
finds a record based on criteria i have determined and then copy th
found range.

So far i have been able to create a routine that finds the value i wan
and then uses offset to point at the first cell in the range i want t
copy. see below

Set Dcell = sh1.Cells.find(sCode)

Dcell.Offset(4, 0).Select

I know want to be able to create a range that is based on how man
records are beneath dcell, e.g. dcell may contain data for 1997 and th
cell below it data for 1998 and so. Is there away to dynamically loo
down the range until a blank cell is found, thus declaring that as th
end of the range?

Do i need to use offset and countA OR resize Or a combination of both?

so far ive been trying following to no evail, thanks

cell1.Offset(1,0).Resize(1,5).copy _
destination:=cell.offset(0,1) -- not dynamic

Set dynRng = offset(dcell,0,0,CountA(dcell&:&dcell)

--
cereldin
-----------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...fo&userid=3206
View this thread: http://www.excelforum.com/showthread.php?threadid=53158

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using .resize or an offset


prob should have mentioned that the find function means that dcell could
be any column in worksheet. Am i right in thinking that if i wanted to
use an offset then i would need to declare which column to read down
e.g OFFSET($A$,0,0,COUNTA($A:$A ets


--
cereldine
------------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=531581

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default using .resize or an offset

I'd just look under the dCell. If it's empty, you're done. If that cell isn't
empty, you can essentially hit the End key followed by the down arrow to find
that last filled cell in that area.

Option Explicit
Sub testme()

Dim dCell As Range
Dim dCellBot As Range

Set dCell = ActiveSheet.Range("C3") 'or the results of your find

If dCell Is Nothing Then
'what happens if it isn't found?
ElseIf IsEmpty(dCell.Offset(1, 0).Value) Then
Set dCellBot = dCell
Else
Set dCellBot = dCell.End(xlDown)
End If

If dCell Is Nothing Then
'do nothing
Else
ActiveSheet.Range(dCell, dCellBot).Copy _
Destination:=whereeveryouwanttogo
End If

End Sub



cereldine wrote:

I'm looking to create a routine that opens up external worksheet and
finds a record based on criteria i have determined and then copy the
found range.

So far i have been able to create a routine that finds the value i want
and then uses offset to point at the first cell in the range i want to
copy. see below

Set Dcell = sh1.Cells.find(sCode)

Dcell.Offset(4, 0).Select

I know want to be able to create a range that is based on how many
records are beneath dcell, e.g. dcell may contain data for 1997 and the
cell below it data for 1998 and so. Is there away to dynamically look
down the range until a blank cell is found, thus declaring that as the
end of the range?

Do i need to use offset and countA OR resize Or a combination of both?

so far ive been trying following to no evail, thanks

cell1.Offset(1,0).Resize(1,5).copy _
destination:=cell.offset(0,1) -- not dynamic

Set dynRng = offset(dcell,0,0,CountA(dcell&:&dcell))

--
cereldine
------------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=531581


--

Dave Peterson
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
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Why Copy/Paste fails using Offset & Resize of myRange? [email protected] Excel Discussion (Misc queries) 3 November 21st 06 02:06 AM
I could NOT resize the axis title but excel allows me to resize gr Iwan Setiyono Ko Charts and Charting in Excel 4 June 6th 06 04:46 AM
RESIZE PROPERTY: is it possible to resize "up" and "to the left"? Myles[_57_] Excel Programming 1 March 22nd 06 04:57 AM
I could NOT resize the axis title but excel allows me to resize gr Iwan Setiyono Ko Charts and Charting in Excel 0 March 15th 06 10:34 AM


All times are GMT +1. The time now is 04:31 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"