Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting a single row range


I have some code to find a value in a worksheet:


Code:
--------------------

Cells.Find(What:="HTD Total", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
--------------------


I need to be able, once found, to offset by 4 rows to the right and
then select the next 12 rows and copy.

basically 4 cells to the right of 'HTD Total' is a row of 12 cells I
need to copy.

what is the syntax for the selecting this range?

thanks in advance,


--
matpj
------------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=481912

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Selecting a single row range

Your code needs to handle the case where what you are looking for is not
found. Here is some code for you to try...

Sub Test()
Dim rngFound As Range
Dim rngCopyArea As Range
Dim wks As Worksheet

Set wks = ActiveSheet
Set rngFound = wks.Cells.Find("HTD Total")

If rngFound Is Nothing Then
MsgBox "HTD Total was not found"
Else
Set rngCopyArea = wks.Range(rngFound.Offset(0, 4),
rngFound.Offset(0, 16))
rngCopyArea.Copy Sheets("Sheet2").Range("A1")
End If
Set wks = Nothing
Set rngFound = Nothing
Set rngCopyArea = Nothing
End Sub

--
HTH...

Jim Thomlinson


"matpj" wrote:


I have some code to find a value in a worksheet:


Code:
--------------------

Cells.Find(What:="HTD Total", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
--------------------


I need to be able, once found, to offset by 4 rows to the right and
then select the next 12 rows and copy.

basically 4 cells to the right of 'HTD Total' is a row of 12 cells I
need to copy.

what is the syntax for the selecting this range?

thanks in advance,


--
matpj
------------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=481912


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
Find a single value from tables by selecting two variable inputs? jj023 Excel Worksheet Functions 8 February 17th 10 01:40 AM
select a single cell in excel 07, currently selecting a goup pjrick Excel Discussion (Misc queries) 2 July 8th 09 07:53 PM
Excel 2002: Single step of selecting characters Mr. Low Excel Discussion (Misc queries) 5 May 4th 07 05:12 PM
selecting a single sheet from a volume of sheets in a workbook No News Excel Worksheet Functions 12 July 1st 06 05:29 AM
Selecting single column with merged cell at top Paul Kendall[_5_] Excel Programming 3 October 29th 03 09:01 PM


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