Rule only works once..?

Rule only works once..?

LSA-skan
Advocate Advocate
444 Views
3 Replies
Message 1 of 4

Rule only works once..?

LSA-skan
Advocate
Advocate

I have made this rule, that should fill out a cell in a spreadsheet with a text from IProperties.. but it seem to work only the first time. 2nd time i run it, nothing happends... not even the msgbox at the end...?!

 

Any ideas?

 

GoExcel.Open("I:\TEGNINGSNUMRE SKEMAER\Standard nummer udtagning-test.xlsx", "80000")
'Get new partnumber from Excel'Find next empty row in Column BFor RowPN = 2 To 1000
RowPN = RowPN + 1
If GoExcel.CellValue("B" & RowPN) = 1 Then
'Insert title from open Document
GoExcel.CellValue("C" & RowPN) = iProperties.Value("Summary", "Title")
End If
Next

GoExcel.Save()
0 Likes
445 Views
3 Replies
Replies (3)
Message 2 of 4

LSA-skan
Advocate
Advocate

This actully only works on that one row...! if i remove the text so it is suposed to add iProperties the the cell before, it´s not doing anything either... only Row 43 works, which i find very odd, since im not refering to it anywhere..?!?

 

/LSA

 

EDIT: After adding som more Rows with the number 1 (there should only be a single row with 1 at any one time.) it works for every other row with 1 in it..?!?

 

I realy need some help with this, as im totally blank on whats going on...! O.o

 

/LSA

0 Likes
Message 3 of 4

LSA-skan
Advocate
Advocate

ok.. i worked out why it does every other row, apparently the RowPN = RowPN + 1 should not be there... 

 

BUT... now i need the code to stop when it gets to the first Cell containing [1].. as a formula in Excel automatically changes the next cell to become [1]... 

 

Im propably doing this the complete wrong way, but as a rookie im just trying what ever comes to mind, with a mix of what i find on the forum...

 

The optimal code would go in the Excel spreadsheet, find the first empty cell, and put iProperty info there...

 

/LSA

0 Likes
Message 4 of 4

LSA-skan
Advocate
Advocate

The code should of course look like this..!

GoExcel.Open("I:\TEGNINGSNUMRE SKEMAER\Standard nummer udtagning-test.xlsx", "80000")
'Get new partnumber from Excel'Find next empty row in Column B
For RowPN = 2 To 1000
If GoExcel.CellValue("B" & RowPN) = 1 Then
'Insert title from open Document
GoExcel.CellValue("C" & RowPN) = iProperties.Value("Summary", "Title")
End If
Next

GoExcel.Save()

 

0 Likes