Solved

Macro for Excel: Find Cell that matches value of other cell and paste clipboard

Posted on 2001-07-12
2
232 Views
Last Modified: 2012-06-27
Hi there,

I've got an Excel-Workbook with several sheets and want to attach a macro with a button on one of them. The macro is supposed to copy a defined range Selection and paste it on another sheet in a cell on another sheet (DestCell). DestCell is on another sheet and shall be depending on the current date (found in DateCell). DestCell is located two collums right of a cell with matching content to DateCell.

I've got the copy and paste stuff covered, but I'm struggeling with activating DestCell, i.e. finding the matching cell for DateCell on the DestinationSheet.

Thanks, Chris
0
Comment
Question by:fizher
2 Comments
 
LVL 5

Accepted Solution

by:
Draak earned 200 total points
ID: 6279564
  Hi,

here is some code to search for a certain cell containing specific data and then activating this cell. Here I'm looking for the value 07/13/01 in a range I selected.

    'define a cell
    Dim aCell As Variant
   
    'Select the range
    Range("D9:D18").Select
   
    'Find the cell you are looking for
    'the data you are looking for should be between the quotes behind What:=
    Set aCell = Selection.Find(What:="07/13/01", After:=ActiveCell, LookIn:=xlValues, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False)
   
    'Select the cell if it has been found
    If Not aCell Is Nothing Then
        aCell.Select
    End If

You can easily replace the value to search for with the content of your destcell.

best regards

Draak
0
 

Author Comment

by:fizher
ID: 6281726
Hi Draak,

thanks for the code - that was basically what I had in my code before, but it showed me that it wasn't this part that didn't work. (I defined a string (MToaday) as Range("A1").Value instead of Range("A1").Text - so it wouldn't find it and the value didn't exist in the defined search range - so thanks again.

Best, Chris
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question