tatendatiffany
Board Regular
- Joined
- Mar 27, 2011
- Messages
- 103
my loop doesn't seem to be doing anything, its not giving me any error of the problems within the loop but is is not doing anything could someone enlighten me as to why. also i want to add another code to tell excel where to display the results from each run how do i do that
Code:
Public Sub LoopQueries()
Dim SQL1 As Variant
Dim c As Range
SQL1 = ThisWorkbook.Worksheets("Index").Range("Environ4")
For Each c In ThisWorkbook.Worksheets("Index").Range("Environ4")
c.Offset(, 2).Value = c.Value
Next c
End
' THIS IS CONNECTION TO AMA4 RUNNING THROUGH ENTIRE COLUMN
Dim SQL2 As Variant
Dim d As Range
SQL2 = ThisWorkbook.Worksheets("Index").Range("Environ1")
For Each d In ThisWorkbook.Worksheets("Index").Range("Environ1")
d.Offset(, 2).Value = d.Value
Next d
End
'THIS CONNECTS TO AM1 AND IS RUNNING THROUGHOUT THE COLUMN
Dim SQL3 As Variant
Dim e As Range
SQL3 = ThisWorkbook.Worksheets("Index").Range("Environ3")
For Each e In ThisWorkbook.Worksheets("Index").Range("Environ3")
e.Offset(, 2).Value = e.Value
Next e
End
' THIS IS CONNECTION TO AMA3 RUNNING THROUGH ENTIRE COLUMN
Dim SQL4 As Variant
Dim f As Range
SQL3 = ThisWorkbook.Worksheets("Index").Range("Environ5")
For Each f In ThisWorkbook.Worksheets("Index").Range("Environ5")
f.Offset(, 2).Value = f.Value
Next f
End
' THIS IS CONNECTION TO AM5 RUNNING THE ENTIRE COLUMN
Dim SQL5 As Variant
Dim g As Range
SQL3 = ThisWorkbook.Worksheets("Index").Range("Environ7")
For Each g In ThisWorkbook.Worksheets("Index").Range("Environ7")
g.Offset(, 2).Value = g.Value
Next g
End
End Sub