+ Reply to Thread
Results 1 to 2 of 2

Selecting relative cells in a macro?

  1. #1
    Registered User
    Join Date
    10-20-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    1

    Question Selecting relative cells in a macro?

    Hello! I'm very new to macros, but I'm trying to do something that I'm afraid might not be possible. Can someone help me?

    Here's what I'm trying to do:

    I have a large workbook with many tabs filled with data. Once I finish updating the data each week, I copy some of it into a separate tab filled with Historic Data. That tab has rows labeled by dates so I can go back and see the data each week going back a year or two. The data I pull (copy/paste) comes from 4 different lines in 2 different tabs.

    Here's what I've gotten so far:

    1. The macro goes to Tab A and copies the correct date (which I have edited before saving the new document for that week).

    2. The macro then goes to Tab C (historic data), and highlights the columns where my first piece of historic data should go.

    3. The macro pulls up the find window and pastes the date from the previous tab. Then it can find that date (which is already on there because I filled those out months out).

    (The idea here is that I'm telling it to search for today's date so that I can be sure to place today's data into the right row.)

    4. Finally, the macro hits tab to go to the next cell, which is empty and waiting for the historic data to be filled in.

    ***Everything up to this point WORKS!*** (And I'm very proud of myself for figuring out how to get that far).

    Here's my issue. I now need to tell the macro to actually *select* the targeted cell. When I try to go back and copy/paste into that tab, it pastes it at the top of the page because technically, that cell is just "found" but not targeted. Part of the issue might be that I had to select multiple columns so those are the "cells" that are currently selected. And I can't skip that step, because there are 3 different cells with the right date on that tab for 3 of the 4 pieces of data and I need to make sure that each line of data goes in the right spot. I can't just tell the macro to target a specific cell, because the correct cell will change every week as I have to enter data in the line below the previous one. So... I'm stumped.

    Have I confused people? I'm open to suggestions!

    (I have only started to learn basic recording of macros, but if anyone can point me in the direction of how to actually program that little detail into the visual basic, I'll be happy with that, too).



    Edit: Sorry, here's a copy of the document (edited to take out sensitive info). I'm trying to tell it to take one block of data from the "Report" tab and 3 lines of data from the "Prices" tab and put them into various places on the "Historic Data" tab. They data is highlighted or bordered in light blue, with comments explaining where each one needs to go.

    Does this help? I'm sorry if it's confusing!
    Attached Files Attached Files
    Last edited by lady2beetle; 10-20-2010 at 12:09 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Selecting relative cells in a macro?

    Hello lady2beetle,

    Welcome to the Forum!

    Please post your workbook. With the workbook,. we can then see the full layout, formulas, formatting, and any macro code the workbook contains. This saves time, and provides a way to test the code before the solution is provided, ensuring you get fast and accurate results.

    To Attach a File:
    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1