PDA

View Full Version : Sleeper: Look right until there are no more cells with content



crmpicco
06-09-2005, 04:36 AM
In this code i am building a HTML table. I am going along a spreadsheet and when it finds a cell with data it will build a <td> tag then close it with a </td>.
The code sRightRange = getColumnLetter(iCol + iFlag) & iRow has a value of
A10 for example and is the range that is being looked in at that time.

However, what i need the code to be able to do is look right (as it does at the moment), however until there are no values in ANY cells to the right - and NOT just the first one directly right.

How can this be done?

I can post more of the code if required.



While flag <> True
sRightRange = getColumnLetter(iCol + iFlag) & iRow
'... if it is not empty then write another <td>
If iFlag = 0 And Trim(Range(sRightRange).Text) <> "" Then
the_Content = the_Content & "&lt;tr&gt;"
the_Content = the_Content & "&lt;td&gt;"
the_Content = the_Content & fix_ampersand_to_amp(Trim(Range(getColumnLetter(iCol + iFlag) & iRow).Text))
the_Content = the_Content & "&lt;/td&gt;"
ElseIf iFlag = 0 And Trim(Range(sRightRange).Text) = "" Then
the_Content = the_Content & "&lt;tr&gt;"
the_Content = the_Content & "&lt;td&gt;"
the_Content = the_Content & fix_ampersand_to_amp(Trim(Range(getColumnLetter(iCol + iFlag) & iRow).Text))
the_Content = the_Content & "&lt;/td&gt;"
the_Content = the_Content & "&lt;/tr&gt;"
flag = True
ElseIf iFlag <> 0 And Trim(Range(sRightRange).Text) = "" Then
the_Content = the_Content & "&lt;td&gt;"
the_Content = the_Content & fix_ampersand_to_amp(Trim(Range(getColumnLetter(iCol + iFlag) & iRow).Text))
the_Content = the_Content & "&lt;/td&gt;"
the_Content = the_Content & "&lt;/tr&gt;"
flag = True
ElseIf iFlag <> 0 And Trim(Range(sRightRange).Text) <> "" Then
the_Content = the_Content & "&lt;td&gt;"
the_Content = the_Content & fix_ampersand_to_amp(Trim(Range(getColumnLetter(iCol + iFlag) & iRow).Text))
the_Content = the_Content & "&lt;/td&gt;"
End If
iFlag = iFlag + 1
Wend

crmpicco
06-09-2005, 04:39 AM
this should explain it better.

crmpicco
06-09-2005, 04:54 AM
While flag <> True
sRightRange = getColumnLetter(iCol + iFlag) & iRow
sDblRightRange = getColumnLetter(iCol + iFlag + 1) & iRow
sTrbRightRange = getColumnLetter(iCol + iFlag + 2) & iRow
sQuaRightRange = getColumnLetter(iCol + iFlag + 3) & iRow
'... if it is not empty then write another <td>
If iFlag = 0 And Trim(Range(sRightRange).Text) <> "" Then
the_Content = the_Content & "&lt;tr&gt;"
the_Content = the_Content & "&lt;td&gt;"
the_Content = the_Content & fix_ampersand_to_amp(Trim(Range(getColumnLetter(iCol + iFlag) & iRow).Text))
the_Content = the_Content & "&lt;/td&gt;"
ElseIf iFlag = 0 And Trim(Range(sRightRange).Text) = "" And _
Trim(Range(sDblRightRange).Text) = "" And _
Trim(Range(sTrbRightRange).Text) = "" And _
Trim(Range(sQuaRightRange).Text) = "" Then
the_Content = the_Content & "&lt;tr&gt;"
the_Content = the_Content & "&lt;td&gt;"
the_Content = the_Content & fix_ampersand_to_amp(Trim(Range(getColumnLetter(iCol + iFlag) & iRow).Text))
the_Content = the_Content & "&lt;/td&gt;"
the_Content = the_Content & "&lt;/tr&gt;"
flag = True
ElseIf iFlag <> 0 And Trim(Range(sRightRange).Text) = "" And _
Trim(Range(sDblRightRange).Text) <> "" Then
the_Content = the_Content & "&lt;td&gt;"
the_Content = the_Content & fix_ampersand_to_amp(Trim(Range(getColumnLetter(iCol + iFlag) & iRow).Text))
the_Content = the_Content & "&lt;/td&gt;"
ElseIf iFlag <> 0 And Trim(Range(sRightRange).Text) = "" And _
Trim(Range(sDblRightRange).Text) = "" And _
Trim(Range(sTrbRightRange).Text) = "" And _
Trim(Range(sQuaRightRange).Text) = "" Then
the_Content = the_Content & "&lt;td&gt;"
the_Content = the_Content & fix_ampersand_to_amp(Trim(Range(getColumnLetter(iCol + iFlag) & iRow).Text))
the_Content = the_Content & "&lt;/td&gt;"
the_Content = the_Content & "&lt;/tr&gt;"
flag = True
ElseIf iFlag <> 0 And Trim(Range(sRightRange).Text) <> "" Then
the_Content = the_Content & "&lt;td&gt;"
the_Content = the_Content & fix_ampersand_to_amp(Trim(Range(getColumnLetter(iCol + iFlag) & iRow).Text))
the_Content = the_Content & "&lt;/td&gt;"
End If
iFlag = iFlag + 1
Wend

that code seems to work ok, but is there a way to make it more dynamic instead of setting 4 ranges everytime?

crmpicco
06-09-2005, 09:53 AM
any ideas welcome