Solved

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

Posted on 2001-07-12
2
220 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now