Results 1 to 4 of 4

Loops using multiple variables

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Smile Loops using multiple variables

    Hi

    I am trying to create a macro which does mutiple things and i am having trouble with it and i was wondering if anyone can help me?

    I have currently got a the macro in the notepad document i have attachted.

    However i need to change this so instead of looping for that strFile variable it loops through the following file names:

    Graphing_MTH_Actual_Curr_Year" & "*.csv
    Graphing_MTH_Actual_Prev_Year" & "*.csv
    Graphing_YTD_Actual_Curr_Year" & "*.csv
    Graphing_YTD_Actual_Prev_Year" & "*.csv
    Graphing_R12_Actual_Curr_Year" & "*.csv
    Graphing_R12_Actual_Prev_Year" & "*.csv

    But i also need to change it so instead of just pasting it into the MTH sheet it pastes it in different sheets depending on the file name. So:
    • If the filename is Graphing_MTH_Actual_Curr_Year" & "*.csv it pastes the data in MTH
    • If the filename is Graphing_MTH_Actual_Prev_Year" & "*.csv it pastes the data in MTHPrevious
    • If the filename is Graphing_YTD_Actual_Curr_Year" & "*.csv it pastes the data in YTD
    • If the filename is Graphing_YTD_Actual_Prev_Year" & "*.csv it pastes the data in YTDPrevious
    • If the filename is Graphing_R12_Actual_Curr_Year" & "*.csv it pastes the data in R12
    • If the filename is Graphing_R12_Actual_Prev_Year" & "*.csv it pastes the data in R12Previous

    I hope this makes sense. I am having really trouble with this as i have got it to loop through the strFldr and lookup strFile and copy and paste the correct data into the MTH tab but i can not work out how to get it to loop through multiple factors. I have thought about using select case statements and loops within loops but i am not sure how either of them work.

    Can anyone help me?

    Thanks

    Jeskit
    Attached Files Attached Files
    Last edited by jeskit; 04-11-2011 at 05:31 AM.

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