Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 275
Default Code help - search / copy-paste

Hi all,

being a bit of a novice and getting lots of help from this site I have tried
to write my own code, but as I am getting errors with it, I thought I would
ask for help....again !

Basically I want some code to search through column D of sheet
ReportDatabase for the date shown in cell D2 of sheet1.
Once this date is matched copy that row A:C and paste into row2 of the
DisplayReport sheet

any help appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Code help - search / copy-paste

Sub DoTonysStuff()
Dim ReportDBSheet As Worksheet
Dim DisplayReport As Worksheet
Dim FoundCell As Range
Dim SearhCell As Range
Dim SearchRange As Range
Dim FoundRange As Range
Dim x
Set ReportDBSheet = ActiveWorkbook.Worksheets(1)
Set DisplayReport = ActiveWorkbook.Worksheets(2)
Set SearhCell = ReportDBSheet.Range("D2")
Set SearchRange = ReportDBSheet.Range("D:D")
Set FoundCell = SearchRange.Find(What:=SearhCell.Value, LookIn:=xlValues)
x = 1

For Each FoundCell In SearchRange
If FoundCell = SearhCell Then
FoundCell.Copy Destination:=DisplayReport.Cells(x, 1)
x = x + 1
End If
Next
End Sub
This might take a little modifying but try:



"Anthony" wrote:

Hi all,

being a bit of a novice and getting lots of help from this site I have tried
to write my own code, but as I am getting errors with it, I thought I would
ask for help....again !

Basically I want some code to search through column D of sheet
ReportDatabase for the date shown in cell D2 of sheet1.
Once this date is matched copy that row A:C and paste into row2 of the
DisplayReport sheet

any help appreciated

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Code help - search / copy-paste

This is untested:

Sub SeachnPaste()
Dim c As Range, myRange As Range, lr As Long
lr = ActiveSheet.Cells(Rows.Count, 4).End(xlUp).Row
myRange = ActiveSheet.Range("D3:D" & lr)
For Each c In myRange
If c.Value = Range("D2").Value Then
Range("A" & c.Row & ":C" & c.Row).Copy _
Sheets("DisplayReport").Range("A2")
End If
Next
End Sub

"Anthony" wrote:

Hi all,

being a bit of a novice and getting lots of help from this site I have tried
to write my own code, but as I am getting errors with it, I thought I would
ask for help....again !

Basically I want some code to search through column D of sheet
ReportDatabase for the date shown in cell D2 of sheet1.
Once this date is matched copy that row A:C and paste into row2 of the
DisplayReport sheet

any help appreciated

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code help - search / copy-paste

Your write up makes it sound like there will be only one date in Column D on
the ReportDatabase worksheet that will match the date in D2 on Sheet1. If
that is the case, this code should do what you want...

Sub FindSingleDate()
Dim C As Range
With Worksheets("ReportDatabase")
Set C = .Columns("D").Find( _
What:=Worksheets("Sheet1").Range("D2").Value, _
After:=Range("D1"), LookAt:=xlWhole, LookIn:=xlValues)
If Not C Is Nothing Then
C.Offset(0, -3).Resize(1, 3).Copy .Range("A2")
End If
End With
End Sub

Rick


"Anthony" wrote in message
...
Hi all,

being a bit of a novice and getting lots of help from this site I have
tried
to write my own code, but as I am getting errors with it, I thought I
would
ask for help....again !

Basically I want some code to search through column D of sheet
ReportDatabase for the date shown in cell D2 of sheet1.
Once this date is matched copy that row A:C and paste into row2 of the
DisplayReport sheet

any help appreciated


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
Search, copy and paste help [email protected] Excel Discussion (Misc queries) 0 June 15th 07 02:48 AM
VB Code to search,copy,paste and stop at blank row! Anthony Excel Programming 8 February 27th 07 04:14 AM
Search / Copy / Paste RigasMinho Excel Programming 1 July 13th 06 11:25 PM
VBA-code for search,copy and paste TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 December 12th 05 12:40 PM
Search-Copy and Paste-code Bourbon[_29_] Excel Programming 0 January 28th 04 07:54 PM


All times are GMT +1. The time now is 05:33 AM.

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"