Condensing a bunch of GoExcel.CellValue's

Condensing a bunch of GoExcel.CellValue's

AMN3161
Advocate Advocate
243 Views
2 Replies
Message 1 of 3

Condensing a bunch of GoExcel.CellValue's

AMN3161
Advocate
Advocate

I new to VBA but is there a simple way to condensing this to a few lines besides '[ ']?

		iProperties.Value("Custom", "Tag_1") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A1")
		iProperties.Value("Custom", "Tag_2") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A2")
		iProperties.Value("Custom", "Tag_3") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A3")
		iProperties.Value("Custom", "Tag_4") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A4")
		iProperties.Value("Custom", "Tag_5") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A5")
		iProperties.Value("Custom", "Tag_6") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A6")
		iProperties.Value("Custom", "Tag_7") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A7")
		iProperties.Value("Custom", "Tag_8") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A8")
		iProperties.Value("Custom", "Tag_9") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A9")
		iProperties.Value("Custom", "Tag_10") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A10")
		iProperties.Value("Custom", "Tag_11") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A11")
		iProperties.Value("Custom", "Tag_12") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A12")
		iProperties.Value("Custom", "Tag_13") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A13")
		iProperties.Value("Custom", "Tag_14") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A14")
		iProperties.Value("Custom", "Tag_15") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A15")
		iProperties.Value("Custom", "Tag_16") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A16")
		iProperties.Value("Custom", "Tag_17") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A17")
		iProperties.Value("Custom", "Tag_18") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A18")
		iProperties.Value("Custom", "Tag_19") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A19")
		iProperties.Value("Custom", "Tag_20") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A20")
		iProperties.Value("Custom", "Tag_21") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A21")
		iProperties.Value("Custom", "Tag_22") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A22")
		iProperties.Value("Custom", "Tag_23") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A23")
		iProperties.Value("Custom", "Tag_24") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A24")
		iProperties.Value("Custom", "Tag_25") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A25")
		iProperties.Value("Custom", "Tag_26") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A26")
		iProperties.Value("Custom", "Tag_27") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A27")
		iProperties.Value("Custom", "Tag_28") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A28")
		iProperties.Value("Custom", "Tag_29") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A29")
		iProperties.Value("Custom", "Tag_30") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A30")
		iProperties.Value("Custom", "Tag_31") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A31")
		iProperties.Value("Custom", "Tag_32") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A32")
		iProperties.Value("Custom", "Tag_33") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A33")
		iProperties.Value("Custom", "Tag_34") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A34")
		iProperties.Value("Custom", "Tag_35") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A35")
		iProperties.Value("Custom", "Tag_36") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A36")
		iProperties.Value("Custom", "Tag_37") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A37")
		iProperties.Value("Custom", "Tag_38") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A38")
		iProperties.Value("Custom", "Tag_39") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A39")
		iProperties.Value("Custom", "Tag_40") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A40")
		iProperties.Value("Custom", "Tag_41") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A41")
		iProperties.Value("Custom", "Tag_42") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A42")
		iProperties.Value("Custom", "Tag_43") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A43")
		iProperties.Value("Custom", "Tag_44") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A44")
		iProperties.Value("Custom", "Tag_45") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A45")
		iProperties.Value("Custom", "Tag_46") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A46")
		iProperties.Value("Custom", "Tag_47") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A47")
		iProperties.Value("Custom", "Tag_48") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A48")
		iProperties.Value("Custom", "Tag_49") = GoExcel.CellValue(iProperties.Value("Custom", "EXCEL_LOCATION"), "Sheet1", "A49")

I am building this to do about 500 lines and this method of doing it is awful 

 

 

hgh 

0 Likes
Accepted solutions (1)
244 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor
Accepted solution

Something like this?

 

 

Dim excelFile = iProperties.Value("Custom", "EXCEL_LOCATION")
Dim tagsCount As Integer = 49
Dim tagValues = GoExcel.CellValues(excelFile, "Sheet1", "A1", "A" & tagsCount)

For i = 1 To tagValues.Count
	iProperties.Value("Custom", "Tag_" & i) = tagValues.Item(i-1)
Next

 

0 Likes
Message 3 of 3

AMN3161
Advocate
Advocate

This is exactly what i need, thank you so much. I just finished adjusting my rule to use it and its working

 

This is better than looking at a block of text!

0 Likes