Hi Experts,
I wish to know which cell in column M in Excel worksheet that has formula so that it will be the first range address when user selecting a range to be pasted as values. So far, what I've got seems to check the cell which is not blank only. So, it will still return the cell address even it contains values only, not formula. Also, I don't know how to stop the loop once it finds the first cell address with formula.
Below what I have so far. Appreciate some good help, please.
Thank you so much in advance.
I wish to know which cell in column M in Excel worksheet that has formula so that it will be the first range address when user selecting a range to be pasted as values. So far, what I've got seems to check the cell which is not blank only. So, it will still return the cell address even it contains values only, not formula. Also, I don't know how to stop the loop once it finds the first cell address with formula.
Below what I have so far. Appreciate some good help, please.
Code:
Function IsFormula(cell_ref As Range)
IsFormula = cell_ref.HasFormula
End Function
Sub ShowCellWFormula()
Dim j As Integer
Dim DestRng As Range
j = 5
LRow = 8
For j = j To LRow
If Range("M" & j).HasFormula() = False Then
MsgBox "nope"
j = j + 1
End If
Set DestRng = Range("M" & j)
MsgBox DestRng.Address
Next j
End Sub
Thank you so much in advance.
Last edited: