Hi all,
I'm fairly new to VBA. I have a sheet for a daily report ("PlatformReport") which gets overridden with new information each day. I've created a userform button to copy and paste this information into a new sheet within the workbook. So far with my code I am able to copy a defined range and merge these cells ( there often may be varying numbers of rows within each defined range) and I am able to then paste this into a new worksheet in the next available row.
However, instead of pasting to the next available row, I have a date column in column A in this worksheet ("OIMSummary") and have been trying to find a piece of code which will paste the merged cells in the range into the corresponding row which matches today's date. I've found a piece of code which does paste in the row next to todays date, but its doesn't paste the merged cells, it pastes all rows.
Here's the piece of code which pastes the merged cells into the next available row:
Worksheets("PlatformReport").Range("OIM").Copy
Worksheets("OIMSummary").Activate
b = Worksheets("OIMSummary").Range("B" & Rows.count).End(xlUp).Offset(1).Select
ActiveSheet.Paste
Dim MyCell As Range
Dim strMerge(1 To 2) As Variant
Dim i As Integer
For i = 1 To 2
For Each MyCell In Sheets("PlatformReport").Range("LAPlyerNo")
If strMerge(i) = "" Then
strMerge(i) = MyCell.Value
Else
strMerge(i) = strMerge(i) & " " & MyCell.Value
End If
Next MyCell
If finalStr = "" Then
finalStr = strMerge(i)
Else
finalStr = finalStr & Chr(10)
End If
Next
Worksheets("OIMSummary").Activate
Worksheets("OIMSummary").Range("C" & Rows.count).End(xlUp).Offset(1).Value = finalStr
Any help would be greatly appreciated.
Bookmarks