JumboCactuar
Well-known Member
- Joined
- Nov 16, 2016
- Messages
- 788
- Office Version
- 365
- Platform
- Windows
Hi,
i have the following code which works fine
(Copies column A and F to Workbook 2: Column A and B without blanks)
What im wanting is to include the date/time they was copied into workbook 2: column C
If it helps i have a cell already with date/time in original sheet (cell Z1)
so when this occurs
rSel.Copy
ws2.Range("a100000").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
all the blank cells in column C should have the date/time
appreciate any help
i have the following code which works fine
(Copies column A and F to Workbook 2: Column A and B without blanks)
Code:
Sub CopyTest()
Dim WB1 As Workbook, WB2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
Dim Rng As Range, r As Range, rSel As Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set WB1 = ThisWorkbook
Set ws1 = ActiveSheet
Set WB2 = Workbooks.Open("C:\Temp\DataFile.xlsx")
Set ws2 = WB2.Sheets("Sheet1")
WB1.Activate
Set Rng = Range("a2:a" & lastrow)
Set rSel = Nothing
For Each r In Rng
If r.Value <> "" Then
If rSel Is Nothing Then
Set rSel = r
Else
Set rSel = Union(rSel, r)
End If
Set rSel = Union(rSel, r.Offset(0, 6))
End If
Next r
If Not rSel Is Nothing Then rSel.Select
rSel.Copy
ws2.Range("a100000").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
WB2.Close savechanges:=True
End Sub
What im wanting is to include the date/time they was copied into workbook 2: column C
If it helps i have a cell already with date/time in original sheet (cell Z1)
so when this occurs
rSel.Copy
ws2.Range("a100000").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
all the blank cells in column C should have the date/time
appreciate any help