Hi,
This works once and then it doesn't work again.
I can't understand the error.
Any help as usual is most appreciated.
I know the code looks a bit clumsy and maybe a loop would work better, but at least it worksonce.
Option Explicit
Public Sub Trimspaces()
On Error GoTo Err_Trimspaces
Dim Aresponse As Integer
Dim WS1 As Worksheet
Dim DSVdate As Range
Dim UpDateRange As Range
Set WS1 = Sheets("NewToyData")
Set DSVdate = WS1.Range("AM1").End(xlDown).Offset(1, 0)
Set UpDateRange = ActiveCell.Resize(1, 37)
Aresponse = MsgBox("Have you copied the DSV figures from the latest downloaded web-shared spreadsheet?" & vbCrLf & _
"And have you selected the next empty cell down in column A?", vbCritical + vbYesNo, "CRITICAL!")
If Aresponse = vbYes Then
ActiveCell.Offset(, 3).Value = ActiveCell.Offset(0, 7).Value
ActiveCell.Offset(, 7).ClearContents
ActiveCell.Offset(, 6).Value = ActiveCell.Offset(0, 14).Value
ActiveCell.Offset(, 14).ClearContents
ActiveCell.Offset(, 9).Value = ActiveCell.Offset(0, 21).Value
ActiveCell.Offset(, 21).ClearContents
ActiveCell.Offset(, 12).Value = ActiveCell.Offset(0, 28).Value
ActiveCell.Offset(, 28).ClearContents
ActiveCell.Offset(, 15).Value = ActiveCell.Offset(0, 35).Value
ActiveCell.Offset(, 35).ClearContents
ActiveCell.Offset(, 18).Value = ActiveCell.Offset(0, 42).Value
ActiveCell.Offset(, 42).ClearContents
ActiveCell.Offset(, 21).Value = ActiveCell.Offset(0, 49).Value
ActiveCell.Offset(, 49).ClearContents
ActiveCell.Offset(, 24).Value = ActiveCell.Offset(0, 56).Value
ActiveCell.Offset(, 56).ClearContents
ActiveCell.Offset(, 27).Value = ActiveCell.Offset(0, 63).Value
ActiveCell.Offset(, 63).ClearContents
ActiveCell.Offset(, 30).Value = ActiveCell.Offset(0, 70).Value
ActiveCell.Offset(, 70).ClearContents
ActiveCell.Offset(, 33).Value = ActiveCell.Offset(0, 77).Value
ActiveCell.Offset(, 77).ClearContents
ActiveCell.Offset(, 36).Value = ActiveCell.Offset(0, 84).Value
ActiveCell.Offset(, 84).ClearContents
DSVdate = Range("AL1")
UpDateRange.Copy
Dim wbk2 As Workbook
Dim wbk2path As String
' wbk2path = "H:\All\Shipping Database\Call_Offs.xlsm"
wbk2path = "C:\Users\StevieB\Desktop\Call_Offs.xlsm"
Set wbk2 = Workbooks.Open(wbk2path)
MsgBox "Select the row which corresponds to the" & vbCrLf & _
"Saturday you are updating the DSV" & vbCrLf & _
"figures from, and PasteSpecialValues" & vbCrLf & _
"from the G column"
End If
If Aresponse = vbNo Then
Exit Sub
End If
Exit_Trimspaces:
Exit Sub
Err_Trimspaces:
MsgBox Err.Description
Resume Exit_Trimspaces
End Sub