Results 1 to 9 of 9

loop code_ go through 2 date ranges, list of employees and place in value

Threaded View

  1. #1
    Registered User
    Join Date
    04-28-2015
    Location
    sterling heights, MI
    MS-Off Ver
    MI
    Posts
    53

    loop code_ go through 2 date ranges, list of employees and place in value

    Hi the main goal I am trying to do is almost what I did before with a loop but the value is randomly placed everywhere in one spread sheet and not down one column, so I need some help. Also I am seeing that some information is not being grabbed in my loop. Here is my code with some notes inside, along with an attached example.

    Private Sub CommandButton1_Click()
    On Error Resume Next
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Set ws1 = Sheets("Summary")
    Set ws2 = Sheets("Week Summary")
    
    Dim vardate1(283) As Variant 'compare date range list #1-in worksheet "Summary"
    Dim vardate2(283) As Variant 'compare date range list #2-in worksheet "Week Summary"
    
    Dim sinvalue As Double 'random values in one sheet that needs to another sheet
    
    Dim varEngineer As Variant 'compare list 1 of employees-in worksheet "Summary"
    Dim varEngineer2 As Variant 'compare list 2 of employees-in worksheet "Week Summary"
    
    
    Dim x As Integer
    Dim i As Integer
    Dim j As Integer
    Dim g As Integer
    Dim b As Integer
      
    
    
    'ignore this:
    'L = 5
    'Do While L < 300
            'cells(4, L).Value = Cells(5, L).Value
    'L = L + 1
    'Loop
    
    
    
    Do While j < 51
    g = 5
    i = 0
                        Do While i < 283    'goal is to look through these 2 date ranges
                            vardate1(i) = ws1.Cells(2, g).Value
                                Debug.Print vardate1(i) & "    Vardate 1"
                            vardate2(i) = ws2.Cells(4, g).Value
                                Debug.Print vardate2(i) & "       vardate 2" 'it will not grab this value, only the message -PLEASE HELP
                            g = g + 1
                            i = i + 1
                        Loop
    
                   If vardate1(i) <= vardate2(i) Then
                            i = 0
                            g = 5
                            x = 6
                            varEngineer2 = ws2.Cells(1, g).Value
                            varEngineer = ws1.Cells(j, 4).Value
                            sinvalue = ws1.Cells(j, g) ' it will not grab the value-PLEASE HELP
                            Debug.Print varEngineer
                                
                                Do While i < 283
                                         If vardate1(i) = vardate2(i) Then
                                            Cells(x, g).Value = sinvalue
                                        End If
                                x = x + 1
                                i = i + 1
                                g = g + 1
                                Loop
                    End If
    j = j + 1
    Loop
        
    
    
    
    
    End Sub
    Let me know if something doesn't make sense. Thank you!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Count number days absent for different employees with multiple date ranges.
    By monkeypants in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-20-2015, 08:32 PM
  2. Create Unique Overlapping Date Ranges from List of Dates
    By dbs105 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-11-2015, 08:03 PM
  3. Forecast How Many Employees To Hire Based on Active and Termed Employees
    By Kanook22 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-12-2014, 01:19 PM
  4. Deciding on 1st place 2nd place etc for a TOP 10 List
    By Brentsa in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-09-2014, 09:54 PM
  5. [SOLVED] Create list of employees
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-04-2013, 07:44 PM
  6. Replies: 2
    Last Post: 03-11-2013, 09:59 PM
  7. Replies: 5
    Last Post: 02-10-2012, 12:52 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