?
Solved

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

Posted on 2001-07-12
2
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
Draak earned 800 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

762 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