Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Transfer selected rows to sheet

"chris100" wrote in
message ...

[...]
At the moment when there are several dates of the same value in the
column, it will only append the last row of those dates. I need to
append any rows which have the same date as cell A1. Could you please
advise? I looked around but i'm afraid i don't know much about looping
(and evidently everything else in VBA for that matter...)

Regards,

Chris


Ok Chris, only slight modifications: added another
counter (j) to the last For... Next.
Please rerrange as per your need as I worked on my
copy without following your modifications.

--------------------------------------------
Sub CopyRow()
Dim SourceRange As Range, TargetRange As Range
Dim SearchRange As Range, LastWrittenCell As Range
Dim i, n As Integer, k As Integer, j As Integer, ItemToSearchFor
'--------------------------------------
' User definitions
n = 5 ' number of columns to append
Set SourceRange = [AA10]
Set TargetRange = [AG10]
'--------------------------------------
Set SearchRange = Range(SourceRange, SourceRange.End(xlDown))
If IsEmpty(TargetRange) Then
Set LastWrittenCell = TargetRange
k = 0
Else
k = 1
If IsEmpty(TargetRange.Offset(1, 0)) Then
Set LastWrittenCell = TargetRange
Else
Set LastWrittenCell = TargetRange.End(xlDown)
End If
End If

ItemToSearchFor = InputBox("Item To Search For:" & vbCrLf & "(case
sensitive)")
If ItemToSearchFor = "" Then
Exit Sub
End If

For Each i In SearchRange
If i.Value = ItemToSearchFor Then
Range(i, i.Offset(0, n - 1)).Copy LastWrittenCell.Offset(k + j, 0)
j = j + 1
End If
Next

End Sub
-----------------------------------

Ciao
Bruno


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
how do i transfer necessary rows/data from a master sheet victorssb Excel Worksheet Functions 1 September 4th 07 10:52 PM
how do i transfer necessary rows/data from a master excel sheet victorssb Excel Worksheet Functions 0 September 4th 07 10:20 PM
Transfer CELL value and spread it among 24 ROWs on another sheet rhhince[_2_] Excel Worksheet Functions 1 June 22nd 07 11:00 AM
Auto transfer rows from 1 sheet to another by account code. Syd Excel Worksheet Functions 0 March 9th 06 04:05 PM
Automatically transfer selected data to another sheet on print FFW Excel Programming 4 June 20th 05 09:58 PM


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