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!
Bookmarks