+ Reply to Thread
Results 1 to 2 of 2

Macro to update file with condition.

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    19

    Question Macro to update file with condition.

    Hello Guys.

    I'm a newbie in vba scripts and I would your help to find a solution for this case.

    1 - My macro open a file named BancoRM.xlsx (this file do a consult in SQL in a data server and copy the data).
    My first point is: how my macro can open the file BancoRM.xlsx and automatic update the information?

    2 - I think this part is more complex. When i set the macro to import the data range (B5:CJ30000) from BancoRM.xlsx to Pasta2.xlsm i need create a condition to filter only the salaries listed for Rio de Janeiro (state) in the column "E". Any ideia how i can do that?

    Please check my code below.

    Thank you for all support. =)
    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you don't have many posts, even though you have been a member for almost 5 years. --6StringJazzer
    Attached Files Attached Files
    Last edited by hbender; 04-05-2017 at 07:28 AM. Reason: Added a file

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Macro to update file with condition.

    To answer your question 1. You should be able to go to Data -> Connections and select the connection to the database. If you then click on properties, one of them is to refresh on workbook open.

    As for the other question, you will have to filter and then copy the filtered data. If you do a web search on VBA Copy Filtered Data, you will see some examples. Or you can include a sample file here (without sensitive data - change names and account numbers) and we can help you out.

    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.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 05-08-2013, 06:23 AM
  2. Using macro to auto update worksheet accordding certain condition
    By Adamlearnexcel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-30-2012, 09:31 PM
  3. Macro to update an existing file
    By pinkus7 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2012, 04:22 AM
  4. Macro to import large CSV file with condition
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-18-2012, 02:01 AM
  5. Update cell values in master file if changes were made in update file
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-10-2012, 03:03 PM
  6. macro to update multi user file
    By confused 786 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2011, 06:41 PM
  7. Macro to open a file and search based on condition
    By jhc8255 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-15-2010, 01:33 AM
  8. Way to update File names in Macro
    By windpowerfinance in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2010, 02:41 PM

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