Results 1 to 2 of 2

For Each Problems

Threaded View

WadeLair For Each Problems 10-10-2012, 11:24 PM
WadeLair Re: For Each Problems 10-11-2012, 08:25 PM
  1. #1
    Registered User
    Join Date
    06-19-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    40

    For Each Problems

    In my sheet I have attached, I am runnnig a for each loop. I want the macro to run through the sheet and call a series of sub-routines for each hotel listed. What I want to happen is to run all my hotels that have "Friday" selected with one macro.

    I have a For each cell in the hotel information table set up. I want that to find all the instance of Friday for example, then run a series of subs for that Friday, then move on to the next Friday.

    The subs import the files listed in colums k-p, so I also need to figure out how to action those. My idea was to start a variable that would tell me which row was highlighted and then open the files, but if there is a simpler way, I'm open to it.

    I really just need the basic outline for the loop, I have all the sub-routines finished in another version of this where I setup which hotel from the table I want to run the reporting on. This is all standardized, so I figured out I can actually run all these on my coffee break if I can crack through this. Any help is appreciated.

    I have this started, but it is a nightmare.

    Sub TEST()
    
    Dim Locale As Range
    Dim W As Integer
    Range("NumberDOW").Select
    W = Range("NumberDOW").Value
    
    
    Range("DOWNumb").Select
    
    For Each cell In Range("DOWNumb")
    
    If cell.Value = W Then GoTo RunMacros:
    'If cell.Value <> W Then GoTo Message:
    
    
    ActiveCell.Range = Locale
    
    RunMacros:
    MsgBox "You are at the RunMacro label."
    
    If cell.Value = 1 Then GoTo Monday:
    If cell.Value = 2 Then GoTo Tuesday:
    If cell.Value = 3 Then GoTo Wednesday:
    If cell.Value = 4 Then GoTo Thursday:
    If cell.Value = 5 Then GoTo Friday:
    
    Monday:
    Call GetFilePathDailyD
    
    Locale = 0
    
    Tuesday:
    Call GetFilePathDailyD
    
    Locale = 0
    
    
    Message:
    MsgBox "You have no reports to run today."
    
    Next cell
    
    End Sub
    Attached Files Attached Files
    Last edited by arlu1201; 10-11-2012 at 06:16 AM. Reason: Use code tags in future.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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