ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   looping to through rows (https://www.excelbanter.com/excel-programming/395636-looping-through-rows.html)

[email protected]

looping to through rows
 
i am writing a code to output data from a database called PHD to a
sheet called PI_PHD. when you select a range of tags to output from
the values are output across the columns instead of being output down
in rows. this cannot be helped. the way around is to repeat the
database call for each different tag. the code is as follows:

Sub GetData()

Dim StartTime, EndTime, TimeIncrement, TagList, TEMP1, TEMP1_1, TEMP2,
Dim TEMP3

StartTime = "PI_PHD!$B$1,"
EndTime = "PI_PHD!$B$2,"
TimeIncrement = "PI_PHD!$B$3"
TagList = "PI_PHD!$A$7:$A$7,"
TEMP1 = "=PHDGetData(""PHD_HOST"","
'TEMP1_1 = "*=PHDGetData(""PHD_HOST"","
TEMP2 = """"", ""Snapshot"","
TEMP3 = ",0, ""After"", UNI_RET_VALUE, UNI_PRES_MERGED)"
Sheets("PI_PHD").Select
Range("b7") = TEMP1 & TagList & StartTime & EndTime & TEMP2 &
TimeIncrement & TEMP3

End Sub

essentially i want to cycle tag list through A8, A9, A10 etc to the
end of data

please help!


joel

looping to through rows
 
I think this is what you are looking for

Sub GetData()

Dim StartTime, EndTime, TimeIncrement, TagList
Dim TEMP1, TEMP1_1, TEMP2, TEMP3

StartTime = "PI_PHD!$B$1,"
EndTime = "PI_PHD!$B$2,"
TimeIncrement = "PI_PHD!$B$3"
TEMP1 = "=PHDGetData(""PHD_HOST"","
'TEMP1_1 = "*=PHDGetData(""PHD_HOST"","
TEMP2 = """"", ""Snapshot"","
TEMP3 = ",0, ""After"", UNI_RET_VALUE, UNI_PRES_MERGED)"

Sheets("PI_PHD").Select
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = 7 To LastRow

TagList = "PI_PHD!$A$" & RowCount & ":$A$" & _
RowCount & ","
Range("b" & RowCount) = TEMP1 & TagList & StartTime & EndTime & _
TEMP2 & TimeIncrement & TEMP3
Next RowCount
End Sub


" wrote:

i am writing a code to output data from a database called PHD to a
sheet called PI_PHD. when you select a range of tags to output from
the values are output across the columns instead of being output down
in rows. this cannot be helped. the way around is to repeat the
database call for each different tag. the code is as follows:

Sub GetData()

Dim StartTime, EndTime, TimeIncrement, TagList, TEMP1, TEMP1_1, TEMP2,
Dim TEMP3

StartTime = "PI_PHD!$B$1,"
EndTime = "PI_PHD!$B$2,"
TimeIncrement = "PI_PHD!$B$3"
TagList = "PI_PHD!$A$7:$A$7,"
TEMP1 = "=PHDGetData(""PHD_HOST"","
'TEMP1_1 = "*=PHDGetData(""PHD_HOST"","
TEMP2 = """"", ""Snapshot"","
TEMP3 = ",0, ""After"", UNI_RET_VALUE, UNI_PRES_MERGED)"
Sheets("PI_PHD").Select
Range("b7") = TEMP1 & TagList & StartTime & EndTime & TEMP2 &
TimeIncrement & TEMP3

End Sub

essentially i want to cycle tag list through A8, A9, A10 etc to the
end of data

please help!




All times are GMT +1. The time now is 10:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com