Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Find-Copy and Paste

I am trying to create a macro that will find the word "DATE" in column A,
then copy the date in the cell adjacent to it in the same row to cell D2.
Can someone help me with this, I've looked for roughly 2 hours on how to
accomplish and haven't gained any ground....Thanks for your help!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Find-Copy and Paste

Tasha
This macro will find the first instance of "Date" in Column A and will place
the contents of Column B of the same row, into cell D2. Watch out for word
wrap. This macro has only one line besides the Sub and End Sub lines. HTH
Otto
Sub GetDate()
Range("D2").Value = Columns("A:A").Find(What:="Date",
LookAt:=xlWhole).Offset(, 1).Value
End Sub
"Tasha" wrote in message
...
I am trying to create a macro that will find the word "DATE" in column A,
then copy the date in the cell adjacent to it in the same row to cell D2.
Can someone help me with this, I've looked for roughly 2 hours on how to
accomplish and haven't gained any ground....Thanks for your help!!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Find-Copy and Paste

Hi Tasha

You can try this one for a sheet named "Sheet1"

Sub Find_First()
Dim FindString As String
Dim rng As Range
FindString = "DATE"
If Trim(FindString) < "" Then
With Sheets("Sheet1").Range("A:A")
Set rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
rng.Offset(0, 1).Copy rng.Parent.Range("D2")
Else
MsgBox "Nothing found"

End If
End With
End If
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Tasha" wrote in message ...
I am trying to create a macro that will find the word "DATE" in column A,
then copy the date in the cell adjacent to it in the same row to cell D2.
Can someone help me with this, I've looked for roughly 2 hours on how to
accomplish and haven't gained any ground....Thanks for your help!!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Find-Copy and Paste

You can try this:

Range("A2").Select
Do While ActiveCell.Value < ""
If ActiveCell.Value = "DATE" Then
ActiveCell.Offset(0, 3).Value = ActiveCell.Offset(0, 1).Value
End If
ActiveCell.Offset(1, 0).Select
Loop

I'm assuming it's column B which contains the date you want to copy.

The syntax of Activecell.Offset is "row number, column number" so you can
adjust those if need be. 0 = the row or column of the active cell. Positive
values are to the right for columns and down for rows, negative values to the
left for columns and up for rows. The other thing this code assumes is that
you have no blank values in column A. If you do you could change the first
two lines of code to:

Range("A1000").select (or some greater number if you have more rows)
Do While Activecell.Row 1
and the second to last line of code to
ActiveCell.Offset(-1, 0).Select
which would move the cursor up instead of down after each test.

There are prettier ways of coding this, but the way I've shown may be easier
to understand than the more elegant methods.

Hope this helps,

Keith

"Tasha" wrote:

I am trying to create a macro that will find the word "DATE" in column A,
then copy the date in the cell adjacent to it in the same row to cell D2.
Can someone help me with this, I've looked for roughly 2 hours on how to
accomplish and haven't gained any ground....Thanks for your help!!!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Find-Copy and Paste

worked like a charm!! Thanks so much Otto!!!!

"Otto Moehrbach" wrote:

Tasha
This macro will find the first instance of "Date" in Column A and will place
the contents of Column B of the same row, into cell D2. Watch out for word
wrap. This macro has only one line besides the Sub and End Sub lines. HTH
Otto
Sub GetDate()
Range("D2").Value = Columns("A:A").Find(What:="Date",
LookAt:=xlWhole).Offset(, 1).Value
End Sub
"Tasha" wrote in message
...
I am trying to create a macro that will find the word "DATE" in column A,
then copy the date in the cell adjacent to it in the same row to cell D2.
Can someone help me with this, I've looked for roughly 2 hours on how to
accomplish and haven't gained any ground....Thanks for your help!!!




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 Copy and Paste [email protected] New Users to Excel 0 July 3rd 07 02:10 PM
Find/Copy/paste.. then Find/Paste - not working ... at all.... [email protected] Excel Programming 9 November 30th 06 08:49 PM
Find, copy and paste ufo_pilot Excel Discussion (Misc queries) 3 September 7th 06 10:34 AM
Find Copy and Paste RigasMinho Excel Programming 4 July 17th 06 09:32 PM


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