[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2001-07-12
2
Medium Priority
?
242 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
Suggested Courses

649 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