Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Offset from end of a selection

I am trying to copy variable number of cells and then paste them. Then
I am trying to do an Offset form the last cell of the pasted cells. If
I have more than one cell being pasted, the following works great:

Selection.End(xlDown).Activate

However, if there is only one cell being pasted, that syntax will
activate the last cell in the column instead (cell #65536 at the
bottom of the page).

Here is a snippet with my attempt:

Set compRow = Cells.Find(What:="component(s):",
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

Set zipRow = Cells.Find(What:="Zip File:", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
' selects rows of components between comprow and zip row
Range(compRow.Offset(1, 0), zipRow.Offset(-2, 0)).Select

Selection.Copy
Sheets("Condensed ChangeLog").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste

Selection.End(xlDown).Activate


Thank you for any help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Offset from end of a selection

Hi Vic.

To define the ranrge, try something like:

'================
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim iLastRow As Long

Set WB = Workbooks("MyBook.xls") '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE

iLastRow = SH.Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = SH.Range("A1:A" & iLastRow)

End Sub
'<<================


---
Regards,
Norman


"Vic" wrote in message
ups.com...
I am trying to copy variable number of cells and then paste them. Then
I am trying to do an Offset form the last cell of the pasted cells. If
I have more than one cell being pasted, the following works great:

Selection.End(xlDown).Activate

However, if there is only one cell being pasted, that syntax will
activate the last cell in the column instead (cell #65536 at the
bottom of the page).

Here is a snippet with my attempt:

Set compRow = Cells.Find(What:="component(s):",
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

Set zipRow = Cells.Find(What:="Zip File:", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
' selects rows of components between comprow and zip row
Range(compRow.Offset(1, 0), zipRow.Offset(-2, 0)).Select

Selection.Copy
Sheets("Condensed ChangeLog").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste

Selection.End(xlDown).Activate


Thank you for any help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Offset from end of a selection

Vic,

Try:

If Selection.Rows.Count 1 Then
Selection.End(xlDown).Activate
End If


--
Hope that helps.

Vergel Adriano


"Vic" wrote:

I am trying to copy variable number of cells and then paste them. Then
I am trying to do an Offset form the last cell of the pasted cells. If
I have more than one cell being pasted, the following works great:

Selection.End(xlDown).Activate

However, if there is only one cell being pasted, that syntax will
activate the last cell in the column instead (cell #65536 at the
bottom of the page).

Here is a snippet with my attempt:

Set compRow = Cells.Find(What:="component(s):",
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

Set zipRow = Cells.Find(What:="Zip File:", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
' selects rows of components between comprow and zip row
Range(compRow.Offset(1, 0), zipRow.Offset(-2, 0)).Select

Selection.Copy
Sheets("Condensed ChangeLog").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste

Selection.End(xlDown).Activate


Thank you for any help.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Offset from end of a selection

On Apr 21, 3:56 pm, Vergel Adriano
wrote:
Vic,

Try:

If Selection.Rows.Count 1 Then
Selection.End(xlDown).Activate
End If

--
Hope that helps.

Vergel Adriano



"Vic" wrote:
I am trying to copy variable number of cells and then paste them. Then
I am trying to do an Offset form the last cell of the pasted cells. If
I have more than one cell being pasted, the following works great:


Selection.End(xlDown).Activate


However, if there is only one cell being pasted, that syntax will
activate the last cell in the column instead (cell #65536 at the
bottom of the page).


Here is a snippet with my attempt:


Set compRow = Cells.Find(What:="component(s):",
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)


Set zipRow = Cells.Find(What:="Zip File:", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
' selects rows of components between comprow and zip row
Range(compRow.Offset(1, 0), zipRow.Offset(-2, 0)).Select


Selection.Copy
Sheets("Condensed ChangeLog").Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste


Selection.End(xlDown).Activate


Thank you for any help.- Hide quoted text -


- Show quoted text -


Thank you. This worked well!

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
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Find, Copy offset to offset on other sheet, Run-time 1004. Finny[_3_] Excel Programming 10 December 7th 06 11:46 PM
type missmatch on Selection.Offset webby2006[_7_] Excel Programming 2 August 4th 06 03:44 PM
Offset and Range Selection Michael[_28_] Excel Programming 2 March 1st 04 10:43 PM


All times are GMT +1. The time now is 12:29 PM.

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

About Us

"It's about Microsoft Excel"