JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,691
- Office Version
- 365
- Platform
- Windows
I am working on a UDF that processes a large table of data. A small example might look something like this.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]R/C[/TD]
[TD="align: center"]W[/TD]
[TD="align: center"]X[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]Z[/TD]
[TD="align: center"]AA[/TD]
[TD="align: center"]AB[/TD]
[TD="align: center"]AC[/TD]
[TD="align: center"]AD[/TD]
[/TR]
[TR]
[TD="align: center"]24[/TD]
[TD="align: center"]$100[/TD]
[TD="align: center"]4.5[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]B33[/TD]
[TD="align: center"]3/22[/TD]
[TD="align: center"]250[/TD]
[TD="align: center"]2005[/TD]
[/TR]
[TR]
[TD="align: center"]25[/TD]
[TD="align: center"]$250[/TD]
[TD="align: center"]5.8[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"]X21[/TD]
[TD="align: center"]4/15[/TD]
[TD="align: center"]135[/TD]
[TD="align: center"]2011[/TD]
[/TR]
[TR]
[TD="align: center"]26[/TD]
[TD="align: center"]$75[/TD]
[TD="align: center"]1.5[/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"]R03[/TD]
[TD="align: center"]3/29[/TD]
[TD="align: center"][/TD]
[TD="align: center"]1995[/TD]
[/TR]
[TR]
[TD="align: center"]27[/TD]
[TD="align: center"]$110[/TD]
[TD="align: center"]6.0[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]G44[/TD]
[TD="align: center"]4/20[/TD]
[TD="align: center"]400[/TD]
[TD="align: center"]2015[/TD]
[/TR]
</tbody>[/TABLE]
The UDF is passed the table range
The UDF loops through the rows and columns until it completed the work or encounters an error.
In the table above, there is a missing value in AC26. The error occurs when iRow=3 and iCol=7. But these are relative to the first cell in the table. I would like to be able to calculate the actual cell address (AC26 or $AC$26) and show that in a MsgBox.
Can someone help me with the code I need to do that?
Thanks
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]R/C[/TD]
[TD="align: center"]W[/TD]
[TD="align: center"]X[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]Z[/TD]
[TD="align: center"]AA[/TD]
[TD="align: center"]AB[/TD]
[TD="align: center"]AC[/TD]
[TD="align: center"]AD[/TD]
[/TR]
[TR]
[TD="align: center"]24[/TD]
[TD="align: center"]$100[/TD]
[TD="align: center"]4.5[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]B33[/TD]
[TD="align: center"]3/22[/TD]
[TD="align: center"]250[/TD]
[TD="align: center"]2005[/TD]
[/TR]
[TR]
[TD="align: center"]25[/TD]
[TD="align: center"]$250[/TD]
[TD="align: center"]5.8[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"]X21[/TD]
[TD="align: center"]4/15[/TD]
[TD="align: center"]135[/TD]
[TD="align: center"]2011[/TD]
[/TR]
[TR]
[TD="align: center"]26[/TD]
[TD="align: center"]$75[/TD]
[TD="align: center"]1.5[/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]N[/TD]
[TD="align: center"]R03[/TD]
[TD="align: center"]3/29[/TD]
[TD="align: center"][/TD]
[TD="align: center"]1995[/TD]
[/TR]
[TR]
[TD="align: center"]27[/TD]
[TD="align: center"]$110[/TD]
[TD="align: center"]6.0[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]G44[/TD]
[TD="align: center"]4/20[/TD]
[TD="align: center"]400[/TD]
[TD="align: center"]2015[/TD]
[/TR]
</tbody>[/TABLE]
The UDF is passed the table range
Code:
=DoIt(W24:AD27)
Code:
Public Function DoIt(Table as range)
Dim iCol as Integer, iRow as Integer
For iRow = 1 to RowN
For iCol = 1 to ColN
. . . code processing table cells
Next iCol
Next iRow
End Function
Can someone help me with the code I need to do that?
Thanks