Cancel
Showing results for 
Search instead for 
Did you mean: 

Read excel file bypassing free cells by simtalk

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter

Hi all.

How to write a method that reads into an excel spreadsheet sheet bypassing empty cells.
I want to import columns, but when the method encounters an empty cell, it pops up an error.
I am using ActiveX.
I have several columns and different rows.
Attach my current method and excel file.

4 REPLIES

Re: Read excel file bypassing free cells by simtalk

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

the return value is void, if you read once a sting into a any datatype, the data type of this variable will be set to string, this causes the error.

 try this:

 

for i:=1 to xls.range("A1:A24").count loop
		if xls.range("A1:A24").cells(i,1).value /= void then
			term1:=xls.range("A1:A24").cells(i,1).value;
			Matryca[1,Matryca.getColumnYDim(1)+1]:=term1;
		end;		
   next;
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Read excel file bypassing free cells by simtalk

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter
Hi. Thx for your help. But unfortunately still not good. The layout must be the same. So as the value in excel is in a column / cell A3 and above it is empty, then can't in TX be in the table as the first value. 01.png - excel 02.png - TX - bad 03.png - TX - should looks like.

Re: Read excel file bypassing free cells by simtalk

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

then just let the cell empty

 

for i:=1 to 68 loop
  for k:=1 to 24 loop
   if xls.Range("A1:BP24").cells(k,i).value /=void then
    Matryca[i,k]:=to_str(xls.Range("A1:BP24").cells(k,i).value);
   end;
  next; 
 next;
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Read excel file bypassing free cells by simtalk

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter
THX Smiley Very Happy That's exactly what it was Smiley Happy