View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default Column number of last column that returns value ignore formulas

With this test snippet:

Col A to C = text

Col D to W = formulas like: =IF(Mon!D3="","",Mon!D3)

LastCol to return column number of the cell in row 3 that the formula has returned a VALUE.

Thanks.
Howard

Sub LastColumnInOneRow()
'Find the last used column in a Row: row 3 in this example (23)
Dim LastCol As Integer
With ActiveSheet
LastCol = .Cells(3, .Columns.Count).End(xlToLeft).Column
End With
MsgBox LastCol
End Sub