I have the below Macro that works beautifully (Thank you Leith), It finds updated data by current user and current date, then creates a new sheet with the new data. I have an RangetoHTML Function that is used for an automated email from a userform, which does not do what I am needing it to do. I am wondering if I can convert the following Macro to the RangetoHTML function, and if so, how difficult will it be? I have tried a few things, but all I did was mess everything up.
Sub Macro1a()
Dim Cell As Range
Dim CurrentUser As String
Dim DateToPick As Date
Dim EndRow As Long
Dim FirstFind As String
Dim NewSheet As Worksheet
Dim Rng As Range
Dim Row As Long
Dim rngFind As Range
Dim rngPicked As Range
Dim SrcRng As Range
CurrentUser = Environ("username")
DateToPick = Date
'Create New Sheet or add to it.
Set NewSheet = Sheets.Add(After:=ActiveSheet)
NewSheet.Name = Format(DateToPick, "dd-mm-yyyy")
End If
On Error GoTo 0
With Worksheets("Before")
EndRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = .Range("A1:B" & EndRow)
Set SrcRng = .Range("A1:F" & EndRow)
SrcRng.Rows(1).Copy NewSheet.Range("A1")
End With
Set rngFind = Rng.Find(CurrentUser, , xlValues, xlWhole, xlByRows, xlNext, False, False, False)
If Not rngFind Is Nothing Then
FirstFind = rngFind.Address
Set rngPicked = rngFind
Do
Set rngPicked = Union(rngPicked, rngFind)
Set rngFind = Rng.FindNext(rngFind)
If rngFind Is Nothing Then Exit Do
If rngFind.Address = FirstFind Then Exit Do
Loop
Row = NewSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1
For Each Rng In rngPicked.Areas
For Each Cell In Rng.Rows
If Cell.Offset(0, -1) = DateToPick Then
SrcRng.Rows(Cell.Row).Copy NewSheet.Cells(Row, "A")
Row = Row + 1
End If
Next Cell
Next Rng
NewSheet.Columns("A:A").NumberFormat = "mm/dd/yy"
End If
End Sub
Bookmarks