Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,066
- Office Version
- 2016
- Platform
- Windows
I though the code in red was working and for its part it does do the job, but not as I expected. The code in red puts todays date into column A if there is DATA in column B. The code was fine yesterday but not today.
[CODE
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
' Copy from Sheet2 to Sheet1
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Set copySheet = Worksheets("Sheet2")
Set pasteSheet = Worksheets("Sheet1")
copySheet.Range("A1").CurrentRegion.Offset(1, 0).Copy pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
Application.CutCopyMode = False
'Put todays date in column A
Dim LastRow As Long
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
With Range("A2:A" & LastRow)
.Value = Date
.NumberFormat = "dd/mm/yy"
End With
Application.ScreenUpdating = True
End Sub
[/CODE]
The problem is that the code replaces yesterday's date with today. It only puts in todays date in column A and does not keep any previous dates.
[CODE
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
' Copy from Sheet2 to Sheet1
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Set copySheet = Worksheets("Sheet2")
Set pasteSheet = Worksheets("Sheet1")
copySheet.Range("A1").CurrentRegion.Offset(1, 0).Copy pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
Application.CutCopyMode = False
'Put todays date in column A
Dim LastRow As Long
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
With Range("A2:A" & LastRow)
.Value = Date
.NumberFormat = "dd/mm/yy"
End With
Application.ScreenUpdating = True
End Sub
[/CODE]
The problem is that the code replaces yesterday's date with today. It only puts in todays date in column A and does not keep any previous dates.