@kchiba,
YM and MD are just telling DATEDIF which interval to use, the doubles usually mean an interval of one type excluding the other, YM is Months excluding Years, MD is Days excluding Months,
DATEDIF is in Excel 2000 help, I still keep a copy of old Excel versions.
HR can be greatly simplified
Sub HR(ByVal BeginRow As Long, ByVal EndRow As Long, ByVal ChkCol As Variant)
For RowCnt = BeginRow To EndRow
Rows(RowCnt).Hidden = Cells(RowCnt, ChkCol).Value = ""
Next RowCnt
End Sub
Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<<<< change to suit
Dim Lastrow As Long
Dim cnt As Long
Dim i As Long
Application.ScreenUpdating = False
With ActiveSheet
Lastrow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To Lastrow 'Lastrow to...
fred,
LEN(SUBSTITUTE(A1,{"A","a"},"") doesn't produce 113 per se, it produces an array of two values. It does two substitutions, one for A and one for a. The first returns 59 characters, the second 54, giving a total of 113. If you notice, I do a LEN(A1)*2 because I am looking for two letters...
If it is just capital A, then
LEN(A1)-LEN(SUBSTITUTE(A1,"A",""))
If capital and lower-case A, then
=(LEN(A1)-LEN(SUBSTITUTE(A1,"A","")))+(LEN(A1)-LEN(SUBSTITUTE(A1,"a","")))
Try
Private Sub Saveandreturn_Click()
Dim sh As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Me
On Error Resume Next
.Parent.Worksheets(.Range("C2").Value).Delete
On Error GoTo 0
Set sh =...
It is not clear. You say ... No, I don't want to put value of ranges into one cell ..., then you say ... Instead of C4, It gives me the range of C4 to C11 ... Those two statements are contradictory.
You can't put the values from a range of cells into one cell without concatenating them.
You could just use a formula of
=IF(B4,C4,NA())
and just copy down.