sirmacademy
New Member
- Joined
- Aug 12, 2018
- Messages
- 17
I want to insert in a cell a text "Saturday" and "Sunday" but I find it difficult to find the pattern inserting it.
Thank you for your help.
Thank you for your help.
I want to insert in C3, C9 C10, C16 C17, C23 C24, C30 C31.
Sub M1()
Dim x As Long
Dim arr() As Variant
x = Cells(Rows.Count, 2).End(xlUp).Row
arr = Cells(3, 2).Resize(x - 2).Value
For x = LBound(arr, 1) To UBound(arr, 1)
arr(x, 1) = Format(arr(x, 1), "DDDD")
If Left$(arr(x, 1), 1) <> "S" Then arr(x, 1) = vbNullString
Next x
Cells(3, 3).Resize(UBound(arr, 1)).Value = arr
Erase arr
End Sub
Here you go...(PS Hope @Rick Rothestein can post a shorter suggestion using Evaluate.. still trying to learn/understand!)
[table="width: 500"]
[tr]
[td]Sub M2()
With Range("B3", Cells(Rows.Count, "B").End(xlUp))
.Offset(, 1) = Evaluate(Replace("IF(WEEKDAY(@,2)>5,TEXT(@,""dddd""),"""")", "@", .Address))
End With
End Sub[/td]
[/tr]
[/table]
[table="width: 500"]
[tr]
[td]Sub M3()
With Range("B3", Cells(Rows.Count, "B").End(xlUp))
.Offset(, 1) = Evaluate(Replace("IF((@<>"""")*(WEEKDAY(@,2)>5),TEXT(@,""dddd""),"""")", "@", .Address))
End With
End Sub[/td]
[/tr]
[/table]