It'd be helpful to see the entire macro. The code in the body of your posting sets sht to the active worksheet in the workbook identified by the variable Attname. That so, why not
Set Rng = sht.UsedRange
?
Just below that line of code, add
Debug.Print "UsedRange: "; Rng.Address(0, 0, , 1)
Debug.Print "count to right: "; Application.WorksheetFunction.CountA(Range(sht.Columns(Rng.Column + Rng.Columns.Count), sht.Columns(sht.Columns.Count)))
Debug.Print "count below: "; Application.WorksheetFunction.CountA(Range(sht.Rows(Rng.Row + Rng.Rows.Count), sht.Rows(sht.Rows.Count)))
Stop
What does that produce in the VBA Editor's Immediate window?
Re your last question, LastRow and LastCol should both be type Long rather than Double. I'm guessing the problem in Outlook VBA is that it lacks Excel's predefined constants, or enumerations. If so, in my opinion, safer to recreate them as named constants in Outlook VBA code.
The potential problem with this is that if the only nonblank cells are A1 and X99, this will set Rng to A1 rather than A1:X99.
Bookmarks