IgnBan
05-07-2008, 10:27 AM
I have this macro to transfer a data range. After the macro runs the selected range still shows the range copied selected.
I wrote the If statement to see if this will move the focus by selecting cell P59, but the copied range still is show the contour active.
How can I modify the macro to deselect this range after the macro runs?
Private Sub CommandButton1_Click()
Dim strWbkName As String
Dim i As Integer
Dim MyDate As String
MyDate = Date
Application.ScreenUpdating = False
strWbkName = ActiveWorkbook.Name
Workbooks.Open (ActiveWorkbook.Path & "\heatmapleak.xls")
i = 1
Do While ActiveWorkbook.ActiveSheet.Cells(i, 1).Value <> ""
i = i + 1
Loop
Windows(strWbkName).Activate
Sheets("WT_report_sheet_PM").Range("D56:AR56").Copy
Windows("heatmapleak.xls").Activate
Range(Cells(i, 4), Cells(i, 44)).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
i = 1
Do While ActiveWorkbook.ActiveSheet.Cells(i, 1).Value <> ""
i = i + 1
Loop
ActiveWorkbook.ActiveSheet.Cells(i, 1).Value = strWbkName
ActiveWorkbook.Close (True)
Application.ScreenUpdating = True
If MsgBox("Data has been transfered succesfully", vbOKOnly, "Water Test") = vbOK Then
ActiveWorkbook.Activate
Range("P59").Select
End If
I wrote the If statement to see if this will move the focus by selecting cell P59, but the copied range still is show the contour active.
How can I modify the macro to deselect this range after the macro runs?
Private Sub CommandButton1_Click()
Dim strWbkName As String
Dim i As Integer
Dim MyDate As String
MyDate = Date
Application.ScreenUpdating = False
strWbkName = ActiveWorkbook.Name
Workbooks.Open (ActiveWorkbook.Path & "\heatmapleak.xls")
i = 1
Do While ActiveWorkbook.ActiveSheet.Cells(i, 1).Value <> ""
i = i + 1
Loop
Windows(strWbkName).Activate
Sheets("WT_report_sheet_PM").Range("D56:AR56").Copy
Windows("heatmapleak.xls").Activate
Range(Cells(i, 4), Cells(i, 44)).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
i = 1
Do While ActiveWorkbook.ActiveSheet.Cells(i, 1).Value <> ""
i = i + 1
Loop
ActiveWorkbook.ActiveSheet.Cells(i, 1).Value = strWbkName
ActiveWorkbook.Close (True)
Application.ScreenUpdating = True
If MsgBox("Data has been transfered succesfully", vbOKOnly, "Water Test") = vbOK Then
ActiveWorkbook.Activate
Range("P59").Select
End If