Hi:
I need some help with a script to import data from an excel spreadsheet.
Depending on the value in the first column of the spreadsheet I need to create different documents. There are over 100 columns in the spreadsheet - which is challenging enough as it is. I’m trying to use this type of thing:
InitialActivity = .cells(row,1).value
If InitialActivity = "Endorsement" Goto Endorsement
If InitialActivity = "New" Goto NewPolicy
If InitialActivity = "Cancellation" Goto Cancellation
If InitialActivity = "Renewal" Goto Renewal
But I can’t get the processing to go back to the next row in the spreadsheet once the activities in say “Endorsement” have been completed.
Processing starts with this:
'Beginning of loop through the spreadsheet
Do While True
Finish: With xlSheet
row = row + 1
Can anyone give me a hand do that the processing goes to the specific activity type, completes, and then goes back to start the next row in the spreadsheet?
Thanks
Is
Subject: Excel Import
Don’t use Goto Create Subs and use Call, then execution will return to where the sub was called after completing.
You may want to invest in a programming book to get more info on alternatives to GoTo.
Subject: RE: Excel Import
Thanks Carl
Subject: Excel Import
First of all, don’t use goto. At least write some functions where you have your logic, but object oriented Lotusscript will help you stucture your code much better.
Can you post more of your code? If you increase the variable row for each row in the spreadsheet, and you use it in all your references, it should work. I have done similar things myself.
Use the debugger, it will let you see what code is being executed, and the flow of the program.
Subject: Excel Import
Agreeing with the previous respondents, I would structure this as follows:
row = 2 '(Assuming that you have a header row)
Do Until row = lastrow
InitialActivity = .Cells(row, 1).Value
Select Case InitialActivity
Case “Endorsement”
Call CreateEndorsement
Case “New”
Call CreateNew
Case “Cancellation”
Call CreateCancellation
Case “Renewal”
Call CreateRenewal
…
Case Else
MsgBox "Unknown activity - " & InitialActivity & “. Please report this.”, 64, “Processing Error”
End
row = row +1
Loop
HTH!